The plugin Xam.Plugin.Messaging provides us the access to the phone for: calls, SMS and emails. Messaging is one of the most important functions of our device , therefore is frequently used to create applications to get closer to our user, creating a comunication between our App and the system device messaging / call function.
With this plugin we can manage the following topics:
? – Make phone calls
? – Send SMS
? – Send emails
First of all.. What do I need?
- Add from NuGet Package the plugin: Xam.Plugins.Messaging:
Let’s Start!
? Making phone calls
To make a call you just have to do this:
Explaining functionalities:
- CanMakePhoneCall: Returns if the device is available to make calls. ( Gets Bool value )
- MakePhoneCall: This method make phone calls and receives the following parameters:
- PhoneNumber: It’s the phone number that you want to call.
Let’s see an example:
XAML:
C#:
? Sending SMS
Explaining the method:
- CanSendSms: Returns if the device is available to send SMS. ( Gets Bool value )
- SendSms: This method let you send an SMS from your device and receives the following parameters:
- PhoneNumber: It’s the phone number to which you want to send the SMS to.
- Message: It’s the message’s body that you’ll send in the SMS.
Let’s see an example:
XAML:
C#:
? Sending Emails
Explaining the method:
- CanSendEmail: Returns if the device is available to send Emails. ( Gets Bool value )
- CandSendEmailBodyAsHtml: Returns if the device can send an email as an html body. ( Gets Bool value )
- CandSendEmailAttachments: Returns if the device can send an email with attachments.(Gets Bool value )
- SendEmail: This method allows you to send an email from messaging applications available on your device and receives the following parameters:
- EmailTo: It’s the email to which you want to send message to.
- Subject: It’s the message’s subject that you’ll send in the email.
- BodyMessage: It’s the message’s body that you’ll send in the email.
Let’s see an example:
XAML:
C#:
? You can also use the EmailMessageBuilder class the send emails:
How to use it ..?
Done! Good look with your implementation ?
Spanish post:
References:
https://blog.xamarin.com/cross-platform-messaging-for-ios-android-and-windows/