1
votes

I have an application, where the users logs in, gets a registration id from the GCM and send it to the server. My server will use that registration id and GCM to send notifications to the user. Now, I have the following situation: the user goes offline, the server sends him notifications but next time when he logs in, he's doing on a different device getting a new registration id. Is it possible to remove all the notifications from the GCM sent by the server to the old device?

1
are unregistering device when user logout from other device? - Aiyaz Parmar
If user is on different device then user will not get messages as the device id is different from device he has logged in earlier so its obvious he would not get messages. If he is using same device then he would get messages and for that Aiyaz has given you the solution - Pankaj
yes, i am unregistering the device when the user logout, but there is a chance that my application crashes and the user never unregisters the device. - Matei Vlad

1 Answers

1
votes

Frequently calling unregister() is not usually needed (or even advisable) if the user eventually logs back in to the first device, or a new user logs into that device in the future.

There is no way to "take back" a message already sent by the GCM server. You can, however, "screen" incoming messages based on the intended user. If, say, user X is logged on and a message was received and intended for user Y. You can specify user Y as the recipient in a data entry. Since user Y is not the logged in user, discard/ignore the message.

Other settings you might want to look at depending on your needs: time_to_live and delay_while_idle (description here).

Hope I understood your concerns.