Reputation: 429
is there anyway to make a phone call directly without opening the dialler in xamarin.forms?
if (device.PhoneService != null) {
Device.OpenUri(new Uri("tel:123123123"));
}
Upvotes: 15
Views: 11383
Reputation: 3306
When we code to start a voice call, we must be aware of DependencyService in Xamarin.Forms.
DependencyService in Xamarin.Forms provides access to the native functionality and some platform-specific implementations of the iOS, Android and Windows Phone SDKs from your PCL or Shared Project.
To start a voice call there are some platform-specific implementations and permissions.
(source: netdna-cdn.com)
(source: netdna-cdn.com)
Android implementation: Before implementing the interface in Android don't forget to set some permissions in AndroidManifest.xml. These permissions are necessary for invoking a voice call in Android.
(source: netdna-cdn.com)
After setting the permissions we must implement the interface using a small class PhoneCall_Droid.cs.
(source: netdna-cdn.com)
Refer Sample for iOS & Windows Implementation.
(source: netdna-cdn.com)
Upvotes: 6
Reputation: 1359
Devices always show the dialer when you make a phone call, so that the user can hang up, switch to a bluetooth device, mute, etc. - that is how launching a dialer works on mobile. On iOS after the call ends the user will still be in your app, and this question below talks about how to bring the user back to your app on Android after the call ends:
How to make a phone call in android and come back to my activity when the call is done?
Upvotes: 0
Reputation: 3792
Simply use the messaging plugin to do this from shared code. Works great: https://github.com/cjlotz/Xamarin.Plugins
Upvotes: 3