In this recipe, we will learn how to invoke the native mail and messaging applications within our own application.
Add two buttons on the main view of
MainController
. Override theViewDidLoad
method of theMainController
class, and implement it with the following code:this.buttonSendText.TouchUpInside += delegate { NSUrl textUrl = new NSUrl("sms:"); if (UIApplication.SharedApplication.CanOpenUrl(textUrl)){ UIApplication.SharedApplication.OpenUrl(textUrl); } else{ Console.WriteLine("Cannot send text message!"); } } ; this.buttonSendEmail.TouchUpInside += delegate { NSUrl emailUrl = new NSUrl("mailto:"); if (UIApplication.SharedApplication.CanOpenUrl(emailUrl)){ UIApplication.SharedApplication.OpenUrl(emailUrl); } else{ Console.WriteLine("Cannot send e-mail message!"); } } ;
Compile and run the application on the device. Tap on one of the...