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

Getting Started with WNS

Windows Push Notification Services (WNS) is a service that enables you to send push notification messages and updates to Windows 8 (and later) and Windows Phone 8.1 (and later) apps. This section describes how to obtain the WNS prerequisites and send a push notification message using Amazon SNS and WNS.

WNS Prerequisites

To send push notification messages to Windows devices using Amazon SNS and WNS, you need the following:

  • Windows 8 (and later) or Windows Phone 8.1 app configured to use WNS

  • Push notification URI from WNS

  • Package security identifier

  • Secret key

If you already have these prerequisites, then you can send a push notification message to an 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 an App using Amazon SNS and WNS.

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

To send push notification message to your app, you must enable the app for the WNS service. For more information, see Windows Push Notification Services.

Step 2: Get a Push Notification URI from WNS

To create a mobile endpoint with Amazon SNS, you need a push notification URI from WNS. For more information, see Windows Push Notification Services.

Step 3: Get a Package Security Identifier from WNS

To create a mobile endpoint with Amazon SNS, you need a package security identifier from WNS. For more information, see Windows Push Notification Services.

Step 4: Get a Secret Key from WNS

To create a mobile endpoint with Amazon SNS, you need a secret key from WNS. For more information, see Windows Push Notification Services.

Step 5: Send a Push Notification Message to an App using Amazon SNS and WNS

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

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-click the name of the Java project and then click Import, expand General, click File System, click Next, browse to the SNSSamples folder, click OK, and then click 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-click the Java project folder, click Build Path, and then click Configure Build Path...

  2. Click the Libraries tab, and then click Add Library....

  3. Click AWS SDK for Java, click Next, and then click 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.demoWNSAppNotification();. It should look similar to the following:

    Copy
    SNSMobilePush sample = new SNSMobilePush(sns); // TODO: Uncomment the services you wish to use. //sample.demoAndroidAppNotification(); //sample.demoKindleAppNotification(); //sample.demoAppleAppNotification(); //sample.demoAppleSandboxAppNotification(); //sample.demoBaiduAppNotification(); sample.demoWNSAppNotification(); //sample.demoMPNSAppNotification();
  2. Locate the demoWNSAppNotification method and enter the string values for the push notification URI, package security identifier, and secret key.

  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:

    Copy
    String applicationName = "wnspushapp";
  4. Run the application. You should see output similar to the following in the output window of your IDE:

    Copy
    =========================================== Getting Started with Amazon SNS =========================================== {PlatformApplicationArn: arn:aws:sns:us-west-2:111122223333:app/WNS/TestApp} {EndpointArn: arn:aws:sns:us-west-2:111122223333:endpoint/WNS/TestApp/17cc2f2a-dfa8-3450-90c6-e1f88d820f3d} {Message Body: {"WNS":"<badge version=\"1\" value=\"23\"/>"}} {Message Attributes: ("AWS.SNS.MOBILE.WNS.Type": "wns/badge"),("AWS.SNS.MOBILE.WNS.CachePolicy": "cache")} Published! {MessageId=d4899281-927e-5f68-9fd0-de9248be6d47}

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