FosAvance
FosAvance

Reputation: 2469

Publish message to topic

I'm trying to figure out how to publish the same message to a topic. Problem is that topic can consists of subscriptions from iOS and Android users, and there is different payload for iOS and Android.

If I have hashtags users are subscribed to. Do I have to create double topics (iOS+Android) for the same tag?

Upvotes: 0

Views: 362

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269081

The Publish function of Amazon SNS permits different payloads to be delivered to subscribers of different messaging services.

From Send Custom Platform-Specific Payloads in Messages to Mobile Devices:

To send a message to an app installed on devices for multiple platforms, such as GCM and APNS, you must first subscribe the mobile endpoints to a topic in Amazon SNS and then publish the message to the topic. The following example shows a message to send to subscribed mobile endpoints on APNS, GCM, and ADM:

{ 
"default": "This is the default message which must be present when publishing a message to a topic. The default message will only be used if a message is not present for 
one of the notification platforms.",     
"APNS": "{\"aps\":{\"alert\": \"Check out these awesome deals!\",\"url\":\"www.amazon.com\"} }",
"GCM":"{\"data\":{\"message\":\"Check out these awesome deals!\",\"url\":\"www.amazon.com\"}}",
"ADM": "{ \"data\": { \"message\": \"Check out these awesome deals!\",\"url\":\"www.amazon.com\" }}" 
}

Upvotes: 1

Related Questions