S
S
sz92014-10-30 11:34:26
Google
sz9, 2014-10-30 11:34:26

Push notifications with device key change?

Good afternoon.
This is the situation:
- launched the application and logged in as user1. the key from GCM was saved in the database. great, works as it should. I run the script - a notification comes to the device.
- I close the application, open it again and log in with a different user. a new key for user2 is stored in the database, so everything works correctly, I got a different key because I logged in with a different user. in fact, if I received another key, then in GCM it should, as it were, be overwritten for this device. everything seems to be correct.
- I run the script with the user2 key - a notification came. - super
- I run the script with the user1 key - it also came. keys are different. like it shouldn't come.
Who will say what?
Thank you.
----
https://github.com/phonegap-build/PushPlugin
You will typically call this when your app is exiting, to cleanup any resources used.
Its not strictly necessary to call it, and indeed it may be desireable to NOT call it if you are debugging your intermediarry push server.
When you call unregister(), the current token for a particular device will get invalidated, and the next call to register() will return a new token.
If you do NOT call unregister(), the last token will remain in effect until it is invalidated for some reason at the GCM/ADM side.
Since such invalidations are beyond your control, its recommended that, in a production environment, that you have a matching unregister() call, for every call to register(), and that your server updates the devices' records each time.
everything is correct, but why does the old key work .. ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Entelis, 2014-10-30
@sz9

The key is tied to a physical device.
It doesn't matter which user you are logged into the application with, gcm doesn't track it.
99.9% of users use one account on one device, so the question is not very relevant.
If you really want to - you will have to implement it yourself, at the time of the user logout, send a request to the server and delete the token.
apple push works in exactly the same way.

A
Artem Voronov, 2014-10-30
@newross

Are the keys different? If I'm not mistaken, the key is issued for a specific device, not a user.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question