SNS - Getting badge count of devices in a Topic - ios

If you were to publish to 3 devices in a Topic, how can you get an accurate badge count for each of those 3 devices and pass them through?
e.g.
Device A - unread messages 3
Device B - unread messages 5
Device C - unread messages 10
If i publish a message through to the Topic, each device gets the same payload including the same badge number.
Is it possible to somehow upon receiving the push notification, be able to handle the badge number correctly (if app is in the background) somewhere in the AppDelegate?
Or is the only way to get the correct badge number is sending a message via direct messaging? i.e. instead of sending to a topic, you send to individual device tokens.

Publishers send messages to topics. Once a new message is published, Amazon SNS attempts to deliver that message to every endpoint that is subscribed to the topic.
http://docs.aws.amazon.com/sns/latest/dg/PublishTopic.html
When you publish to a topic, you can supply different formats, but not different messages. All subscribers get the same message. Individualized messages have to be sent directly.

Related

How to ensure that Publish message through Pubnub IOS SDK was delivered?

I am attempting to integrate PubNub iOS SDK in my project. How can I confirm that the published message was delivered?
Message Delivered Notification
If the publish callback status is success, then you know PubNub Network received it and sent it to all active subscribers.
If you want to be notified when a subscriber or each individual subscriber (if there are more than one) have received the message, then the subscriber(s) need to send (publish) a message back to the publisher.
But how many subscribers are receiving the message? Do you want to receive a message delivered notification for all subscribers? Just something to consider.

Objective-C How to Determine when Messages App of Apple Sends a sms message

How can I reference the Messages app of apple to my app so I can increment x every time it sends a sms message.
I'm not trying to create an app that sends sms message. It's just a view with a large label that shows a number of how many times I've sent a message from Messages app.

Pubnub iOS push notification filtering?

According to this post, the best practice is filtering channel messages on client side. I haven't found a feasible way to do that when push notification is integrated yet. Right now our iOS client gets notified for a lot of useless messages when app is not running.
Filtering PubNub Messages and Push Notifications
This is a shortcoming with APNS, not PubNub. PubNub works in such a way that all subscribers of a channel receive all messages published on that channel. But when an app is in the background on iOS or not running at all, your app does not have the opportunity to process the push notification before it is displayed by the iOS device. Android/GCM does allow your app to intercept the message before it is displayed.
Fortunately, there is only one scenario (that I can think of) where the sender of a msg would receive their push notification version of the message (meaning, you couldn’t intercept and not display it).
user publishes msg
then immediately (quickly) leaves the app (home button, switch to another app, etc)
push msg appears
But if the user stays in the app for a second or two (or long enough to receive the realtime msg AND the push notification), then you can prevent the push msg from being displayed. But there is no need to filter on UUID because you should be suppressing all push notifications from being displayed when the app is active in the didReceiveRemoteNotification delegate, because you already have the realtime message on the subscribe callback.
That link you referenced (Filter Owner Messages on PubNub Data Streams) is only for realtime push notifications and Stephen is calling out a feature that we will be rolling out in the near future which allows you to subscribe to a channel but provide a query that allows you to filter/query condition for the messages on the channel, like, “where uuid != ”, where is the uuid of the subscriber. Then the subscriber would not receive realtime or push notification messages because the server filters them out for you.
For a good overview of push notifications see Sending APNS and GCM Messages to Subscribers and Mobile Push Notification Services in One API Call
For complete push notification setup, configuration and implementation, see the docs for each of our SDKs.
Also, see my answer that describes how to use iOS silent push notifications to do on device filtering. Same thing can be done on Android but no need to do anything special because you always get the opportunity to process the push notification before it is displayed.

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
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

How WhatsApp implements delivery receipts for messages pushed through Push Notifications in iOS?

An user X(Has Whatsapp in Android) tries to send a message to user Y(Has Whatsapp) in iOS when the user Y is offline. The user Y receives a push notification that he has a message from user X. As soon as the push notification is received, user X is able to see the double tick mark in his WhatsApp client. How WhatsApp is able to figure out that the push notification has been successfully delivered to the iOS client ?
It's not really possible to know what's going on without seeing at least a protocol dump of WhatsApp as this occurs, so on with the rampant speculation:
I'd guess that WhatsApp is using Message Delivery Receipts, which rely on the client responding to the message, rather than the server. Since push notifications talk to an intermediate service (e.g., APNS), which itself wouldn't send said receipt acknowledgements, the client running on the device, upon receiving the push notification, wakes up, analyzes the message, and sends the delivery acknowledgement to the initiator of the dialog.
At least, that's how I'd do it, if I were trying to leverage existing standards, which isn't necessarily what WhatsApp is doing.
Whatsapp uses XMPP, which is TCP based. Thus, if the Server is able to get a connection to Y this should ensure that the message has been delivered.
So if the whatsapp server is able to send the message to Y, the message is pushed out of the server. If Y has enabled the extension to send message states, Y automatically sends a repsone to X with the extension "delivered".
I can't really know, but i would say Whatsapp keeps a service in background that detects it. If i am correct, when you close totally the app (from multitask), and receive a message, the other person won't see a received double tick if you don't open the app.

Resources