Amazon Simple Notification Service
Developer Guide (API Version 2010-03-31)

Getting Started with MPNS

Microsoft Push Notification Service for Windows Phone (MPNS) is a service that enables you to send push notification messages to Windows Phone 7+ and Windows Phone 8.0 apps. This section describes how to obtain the MPNS prerequisites and send a push notification message using Amazon SNS and MPNS. You can send both unauthenticated and authenticated push notification messages with MPNS. For better security and to avoid throttling limits imposed by MPNS, you should send authenticated push notification messages.

MPNS Prerequisites

To send an unauthenticated push notification message to a Windows Phone app using Amazon SNS and MPNS, you need the following:

  • Windows Phone app configured to use MPNS

  • Push notification URI from MPNS

To send an authenticated push notification message to a Windows Phone app using Amazon SNS and MPNS, you also need the following:

  • HTTPS Push notification URI from MPNS

  • Registered as a Windows app developer

  • Transport Layer Security (TLS) certificate

If you already have these prerequisites, then you can send a push notification message to a Windows Phone app using either the Amazon SNS console or the Amazon SNS API. For more information about using the Amazon SNS console, see Using Amazon SNS Mobile Push. For more information about using the Amazon SNS API, see Step 5: Send a Push Notification Message to a Windows Phone app using Amazon SNS and MPNS.

Step 1: Set Up Your Windows Phone App to Receive Push Notifications Messages

To send a push notification message to your Windows Phone app, you must enable the app for the MPNS service. For more information, see Setting up your app to receive push notifications for Windows Phone 8.

Step 2: Get a Push Notification URI from MPNS

To create a mobile endpoint with Amazon SNS you need a push notification URI from MPNS. You can either get an HTTP or HTTPS push notification URI from MPNS. For better security and to avoid throttling limits imposed by MPNS, you should get an HTTPS push notification URI for sending authenticated messages. For more information about getting an HTTPS push notification URI, see Setting up an authenticated web service to send push notifications for Windows Phone 8.

Step 3: Create a Windows Developer Account

To send authenticated messages using MPNS you must create a Windows developer account. For more information about opening a Windows developer account, see Opening a developer account.

Step 4: Upload TLS Certificate

To send authenticated messages using MPNS, you must upload a TLS certificate obtained from one of the trusted certificate authorities (CA) for Windows Phone to your Windows developer account. You must also submit the complete TLS certificate chain and associated private key to Amazon SNS. This is to help with establishing a secure connection to MPNS with Amazon SNS on your behalf. Amazon SNS requires the TLS certificate and private key in the .pem format. You can use different utilities, such as openssl, for converting and exporting certificates. For more information, see Setting up an authenticated web service to send push notifications for Windows Phone 8 and SSL root certificates for Windows Phone OS 7.1. For more information about openssl, see http://www.openssl.org/.

Step 5: Send a Push Notification Message to a Windows Phone app using Amazon SNS and MPNS

This section describes how to use the prerequisite information with the Amazon SNS API to send a push notification message to your Windows Phone app using Amazon SNS and MPNS. You add the gathered prerequisite information to the AWS sample file SNSMobilePush.java, which is included in the snsmobilepush.zip file.

You can also use the Amazon SNS console. However, to send toast notifications, you must use the Amazon SNS API. For more information about using the Amazon SNS console, see Using Amazon SNS Mobile Push.

Note

The following steps use the Eclipse Java IDE. The steps assume you have installed the AWS SDK for Java and you have the AWS security credentials for your AWS account. For more information, see AWS SDK for Java. For more information about credentials, see How Do I Get Security Credentials? in the AWS General Reference.

To add the sample to Eclipse

  1. In Eclipse, create a new Java project (File | New | Java Project).

  2. Import the SNSSamples folder to the top-level directory of the newly created Java project. In Eclipse, right-choose the name of the Java project and then choose Import, expand General, choose File System, choose Next, browse to the SNSSamples folder, choose OK, and then choose Finish.

  3. In the SNSSamples\src\com\amazonaws\sns\samples\mobilepush folder, open the AwsCredentials.properties file and add your AWS security credentials.

To add the AWS SDK for Java to the Build Path

  1. Right-choose the Java project folder, choose Build Path, and then choose Configure Build Path...

  2. Choose the Libraries tab, and then choose Add Library....

  3. Choose AWS SDK for Java, choose Next, and then choose Finish.

To add the prerequisite information to SNSMobilePush.java

  1. In the SNSSamples\src\com\amazonaws\sns\samples\mobilepush folder, open SNSMobilePush.java in Eclipse and uncomment sample.demoMPNSAppNotification();. It should look similar to the following:

    SNSMobilePush sample = new SNSMobilePush(sns); // Uncomment the services you wish to use. //sample.demoAndroidAppNotification(); //sample.demoKindleAppNotification(); //sample.demoAppleAppNotification(); //sample.demoAppleSandboxAppNotification(); //sample.demoBaiduAppNotification(); //sample.demoWNSAppNotification(); sample.demoMPNSAppNotification();
  2. Locate the demoMPNSAppNotification method and enter the notification URI you received from MPNS for the value of the notificationChannelURI string.

  3. Enter a name for your application. Application names must be made up of only uppercase and lowercase ASCII letters, numbers, underscores, hyphens, and periods, and must be between 1 and 256 characters long. For example, it should look similar to the following:

    String applicationName = "mpnspushapp";
  4. Enter the MPNS TLS certificate in .pem file format. You must include the complete certificate chain, beginning with the root CA certificate at the top and ending with the issued certificate at the bottom. At the beginning of each new line in your certificate, you must add \n. For example, it should look similar to the following:

    String certificateChain = "-----BEGIN CERTIFICATE-----\nMIICiTCCAfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMC\nVVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6\nb24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAd\nBgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhcNMTEwNDI1MjA0NTIxWhcN\nMTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYD\nVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25z\nb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFt\nYXpvbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMaK0dn+a4GmWIWJ\n21uUSfwfEvySWtC2XADZ4nB+BLYgVIk60CpiwsZ3G93vUEIO3IyNoH/f0wYK8m9T\nrDHudUZg3qX4waLG5M43q7Wgc/MbQITxOUSQv7c7ugFFDzQGBzZswY6786m86gpE\nIbb3OhjZnzcvQAaRHhdlQWIMm2nrAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAtCu4\nnUhVVxYUntneD9+h8Mg9q6q+auNKyExzyLwaxlAoo7TJHidbtS4J5iNmZgXL0Fkb\nFFBjvSfpJIlJ00zbhNYS5f6GuoEDmFJl0ZxBHjJnyp378OD8uTs7fLvjx79LjSTb\nNYiytVbZPQUQ5Yaxu2jXnimvw3rrszlaEXAMPLE=\n-----END CERTIFICATE-----";
  5. Enter the private key for the MPNS TLS certificate in .pem file format. At the beginning of each new line in your certificate, you must add \n. For example, it should look similar to the following:

    String privateKey = "-----BEGIN RSA PR1VATE KEY-----\nMJICiTCHAfICCQD9m7oRw0uXOjANBgkqhkiG7w0BAQUFADCBiDELMAkGA1UEBhMC\nWVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGx2MQ8wDQYDVQQKEwZBbWF6\nVVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6\n4MXNchZOFFreg4Rr3Xzhb9RhvlIRgsr3wU4/FYai3z96EXAMPLE=\n-----END RSA PR1VATE KEY-----";
  6. Run the application. You should see output similar to the following in the output window of your IDE:

    =========================================== Getting Started with Amazon SNS =========================================== {PlatformApplicationArn: arn:aws:sns:us-west-2:111122223333:app/MPNS/TestApp} {EndpointArn: arn:aws:sns:us-west-2:111122223333:endpoint/MPNS/TestApp/557597f8-be4a-3035-8c6d-bb7fa8b20fef} {Message Body: {"MPNS":"<?xml version=\"1.0\" encoding=\"utf-8\"?><wp:Notification xmlns:wp=\"WPNotification\"><wp:Tile><wp:Count>23</wp:Count><wp:Title>This is a tile notification</wp:Title></wp:Tile></wp:Notification>"}} {Message Attributes: ("AWS.SNS.MOBILE.MPNS.Type": "token"),("AWS.SNS.MOBILE.MPNS.NotificationClass": "realtime")} Published! {MessageId=ce9855bf-395f-5a1a-a4b9-19ace305780d}

    On your Windows Phone, you should see a push notification message appear within the app.