In this recipe, we will learn how to invoke the native Mail and Messaging apps within our own app.
Perform the following steps to invoke the apps:
Add two buttons on the view of
SendTextAppViewController
.Add the following code in the
ViewDidLoad
method:this.btnSendText.TouchUpInside += (s, e) => { NSUrl textUrl = new NSUrl("sms:+123456789"); if (UIApplication.SharedApplication.CanOpenUrl(textUrl)) { UIApplication.SharedApplication.OpenUrl(textUrl); } else { Console.WriteLine("Cannot send text message!"); } } ; this.btnSendEmail.TouchUpInside += (s, e) => { NSUrl emailUrl = new NSUrl("mailto:[email protected]"); if (UIApplication.SharedApplication.CanOpenUrl(emailUrl)) { UIApplication.SharedApplication.OpenUrl(emailUrl); } else { Console.WriteLine("Cannot send email message!"); } } ;
Compile and run the app...