Book Image

JavaScript Mobile Application Development

Book Image

JavaScript Mobile Application Development

Overview of this book

Table of Contents (15 chapters)
JavaScript Mobile Application Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Developing Windows Phone 8 code


As specified in our plugin.xml file's platform section for Windows Phone 8 (wp8), the implementation of our plugin in wp8 is located at src/wp8/Sms.cs. The following code snippet shows Sms.cs code:

using System;
using Microsoft.Phone.Tasks;
using WPCordovaClassLib.Cordova;
using WPCordovaClassLib.Cordova.Commands;
using WPCordovaClassLib.Cordova.JSON;

namespace WPCordovaClassLib.Cordova.Commands
{
  public class Sms : BaseCommand
  {
    public void sendMessage(string options)
    {
      string[] optValues = JsonHelper.Deserialize<string[]>(options);
      String number = optValues[0];
      String message = optValues[1];

      SmsComposeTask sms = new SmsComposeTask();

      sms.To = number;
      sms.Body = message;

      sms.Show();

      /*Since there is no way to track SMS application events in WP8, always send Ok status.*/
      DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "Success"));
    }
  }
}

In order to create our Cordova...