In continuation to blog posts in this series on plugins, today we’ll cover a plugin to make phone calls.
As we understood before, all platforms support phone calling (just like emailing, texting, etc…) and Xamarin makes it easier with one common language – C#. However, developers still need to learn
In case of Windows Phone, one can initiate a phone call by using following code. In this case, Windows Phone has special class which allow developers to perform this task.
In case of Android, developers can use ‘Intent’ and ‘URI activation’ to start a new phone call.
In case of iOS, same concept of URI activation can be applied. As shown below in the code, developers can create a URI with telephone number and it will launch default application to make a phone call.
In previous blog post we’ve seen how we can use plugins to send text messages and use same API across platforms without bothering about individual platform specific APIs. In this blog post we’ll continue to discuss plugins and see how we can send Email messages.
In case of Windows Phone, we can use EmailManager to send EmailMessage. The code will look like:
For Android, there is no class as such which can handle email messaging. Rather, we use something called as Intent.
In case of iOS, we use built-in controller to pass parameters which can populate the email message and later-on send it.
Now, lets see how we can implement this feature in Xamarin.Forms using Plugins. The plugin which we used last time, is feature rich and also included capability to send emails. Refer Messaging Plugin for Xamarin and Windows in your applications and modify the code as shown below. Depending on the platform on which the code is executing, it will internally call the platform specific APIs.
Once again, using this plugin it becomes easy to send Email on Android, iOS and Windows Phone.