Book Image

iOS Development with Xamarin Cookbook

By : Dimitrios Tavlikos (USD)
Book Image

iOS Development with Xamarin Cookbook

By: Dimitrios Tavlikos (USD)

Overview of this book

Table of Contents (22 chapters)
iOS Development with Xamarin Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using text messaging in our application


In this recipe, we will learn how to display the text messaging controller inside our app.

Getting ready

Create a new Single View Application in Xamarin Studio and name it TextMessageApp.

How to do it...

Perform the following steps to display the text messaging controller in our app:

  1. Add a button on the view of the controller.

  2. Enter the following using directive in the TextMessageAppViewController file:

    using MonoTouch.MessageUI;
  3. Implement the ViewDidLoad method with the following code, changing the recipient number and/or the message body at your discretion:

    private MFMessageComposeViewController messageController;
    public override void ViewDidLoad ()
    {
      base.ViewDidLoad ();
      this.btnSendMessage.TouchUpInside += async (s, e) => {
        if (MFMessageComposeViewController.CanSendText)
        {
          this.messageController = new MFMessageComposeViewController();
          this.messageController.Recipients = new string[] { "+123456789012" };
          this.messageController...