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

Creating an Amazon SNS Endpoint for Baidu

This section provides additional information and examples on how to create an Amazon SNS endpoint to use with Baidu. You create an Amazon SNS endpoint, using the combined userId and channelId received from Baidu, to represent the app and mobile device. The endpoint is then used by Amazon SNS for publishing notification messages using the Baidu push notification service to the app on the mobile device.

The following Java example shows how to create an Amazon SNS endpoint for a Baidu app and mobile device.

Map<String ,String> attributes = new HashMap<String ,String>(); // Insert your UserId. This is a mandatory field. attributes.put("UserId", "9999999999"); // Insert your ChannelId. This is a mandatory field. attributes.put("ChannelId", "1234567890"); CreatePlatformEndpointRequest createPlatformEndpointRequest = new CreatePlatformEndpointRequest(); // Baidu endpoints are identified by a combination of the userId and channelId which must be supplied as endpoint attributes, // without which a valid endpoint cannot be successfully created. createPlatformEndpointRequest.setAttributes(attributes); // Insert your ChannelId. This is a mandatory field. createPlatformEndpoint.setPlatformToken("1234567890"); // Insert your Customer User Data. This is an optional field. createPlatformEndpoint.setCustomUserData("Test Endpoint"); // Insert your Platform Application Arn. This is a mandatory field. createPlatformEndpoint.setPlatformApplicationArn("arn:aws:sns:us-west-2:123456789012:app/BAIDU/TestApp"); String endpointArn = snsClient.createPlatformEndpoint(createPlatformEndpointRequest);

Note the following considerations when using the Amazon SNS API to create an endpoint for use with Baidu:

  • In CreateEndpointRequest, the platform token field should contain the channelId.

  • If you specify the endpoint attribute "Token" in the attributes map, this field must encapsulate the channelId as well.

  • The channelId should also be specified as an endpoint attribute with the name "ChannelId".

  • The value of the "ChannelId" endpoint attribute and the platform token field and/or "Token" endpoint attribute must be identical to construct a successful request.

  • The userId should be specified as an endpoint attribute with the name "UserId".

  • For a successful response, the request must contain valid UserId and ChannelId values in the attributes. Also, the ChannelId parameter entered using setPlatformToken(String), which is a part of CreatePlatformEndpointRequest, must be the same as the ChannelId specified in the attributes map.