Question

I know that in never version of GCM you can dismiss notifications based on userId and not device id. This essentially syncs this action with all devices that user is using with same google account. Documentation page for this can be found here and it is quite helpful

http://developer.android.com/google/gcm/notifications.html

Only thing I don't understand from there is: Do I need to write code in my app to contact the GCM sever or my own server to trigger dismissal on other devices or does this happen automatically when notification is dismissed or opened ?

This is the part that led me to think that you need to do it manually but I am not certain : "You should design your app to handle cases where the app receives a dismissal message, but has not yet displayed the notification that is being dismissed."

Was it helpful?

Solution

Yes, you have to write code in your app to trigger the dismissal message, as well as handle it.

Note: A notification dismissal message is like any other upstream message, meaning that it will be delivered to the other devices that belong to the specified notification_key. You should design your app to handle cases where the app receives a dismissal message, but has not yet displayed the notification that is being dismissed. You can solve this by caching the dismissal and then reconciling it with the corresponding notification.

This makes sense, because GCM doesn't know how your app handles an arriving GCM message. Your app might display a notification (which needs to be dismissed if it was already handled on another device belonging to the same user), or it might perform some background sync with the server (in which case no dismissal message needs to be sent).

The point of this new feature is that you send a single message to a single notification key instead of sending it to multiple registration IDs, and an app installed on any of the devices belonging to the same user doesn't need to know the registration IDs of all those devices. It only needs to know the notification_key in order to communicate with the other devices.

OTHER TIPS

i think its your serer that need to be contacted this keeps the flow consistence and also , when contacting GCM server to send message you need to provide your API-key and project Id ... and this is critical to be stored on the mobile application.

thats why you should contact your server, in his turn, your server will contact GCM server

this is my opinion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top