Sending SMS messages

We may be creating an app that requires the user to send an SMS message to a specific number.

How to do it...

To send an SMS message, we make use of the SmsManager instance:

  1. Before we can work with the SmsManager instance, we require a permission:
    [assembly: UsesPermission(Manifest.Permission.SendSms)]
  2. To send the SMS, we only require a single method—SendTextMessage:
    var number = "0123456789";
    var message = "SMS Message Text...";
    var manager = SmsManager.Default;
    manager.SendTextMessage(number, null, message, null, null);

If we need to verify that the message was sent successfully, we can use intents that will be broadcast with the operation status:

  1. First, we have to send the message providing the intents that will be broadcast when ...

Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.