Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon SNS update badge counter for Apple Push Notification when publishing to topic

I understand that it is possible to set the badge counter when publishing to individual devices, but is it possible to set a device independent counter when publishing to ALL devices subscribed to a certain topic ARN?

Current use case is there could be up to a million users subscribed to a certain topic and having to publish push notifications to each device ARN one by one (opposed to a topic ARN) seems really inefficient, from a server-side standpoint.

Frameworks Used

Backend: Python Flask framework with BOTO AWS SDK and SQLAlchemy

Frontend: iOS

like image 897
ken Avatar asked Aug 10 '15 05:08

ken


1 Answers

Short answer

No, you can't.

Apple dont let you send "+1" as badge number, so sending the same badge number to all users that are subscribed to a specific topic should not help you.

Long answer

AWS SNS

AWS SNS let you make custom payloads per platform on the same topic, so it should not be a problem:

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

http://docs.aws.amazon.com/sns/latest/dg/mobile-push-send-custommessage.html#mobile-push-send-multiplatform

{ 
"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\" }}" 
}

Apple

Apple don't let you increment the badge number, so I guess sending the same badge number to all users would not be help you.

Key: Badge

Type: Number

Description: The number to display as the badge of the app icon. If this property is absent, the badge is not changed. To remove the badge, set the value of this property to 0.

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html

like image 110
Wédney Yuri Avatar answered Sep 20 '22 13:09

Wédney Yuri