In this recipe, we will learn how to invoke the native Phone app to allow the user to place a phone call.
Create a new Single View Application in Xamarin Studio and name it PhoneCallApp
.
Perform the following steps to allow the user to place phone calls:
Add a button on the view of
PhoneCallAppViewController
.Add the following code in the
ViewDidLoad
method:this.btnCall.TouchUpInside += (s, e) => { NSUrlurl = new NSUrl("tel:+123456789012"); if (UIApplication.SharedApplication.CanOpenUrl(url)) { UIApplication.SharedApplication.OpenUrl(url); } else { Console.WriteLine("Cannot open url: {0}", url.AbsoluteString); } } ;
Compile and run the app on the device. Tap the Call phone number button to start the call. The following screenshot shows the Phone app placing a call: