Meteor-Community-Packages / raix-push

DEPRECATED: Push notifications for cordova (ios, android) browser (Chrome, Safari, Firefox)
https://atmospherejs.com/raix/push
MIT License
514 stars 197 forks source link

Question: how to deal with abandoned token? #298

Open artpolikarpov opened 7 years ago

artpolikarpov commented 7 years ago

I’ve noticed, that if I uninstall app (without logging out) and than install it again, I’ve got new token in the DB. And system doesn’t delete it even after a while. How to detect those tokens?

I see in code something to remove broken tokens, and actually some of my dev tokens were removed when I tried to send pushes with dev tokens from production servers. But those abandoned tokens stays for ages.

da314pc commented 5 years ago

@artpolikarpov this is late but.. I came across the same problem.

I had to change the package, but here: https://github.com/raix/push/blob/464d82469ca15b8579b469b7156a6c9d16874d9b/lib/server/server.js#L4-L10

When the token is bad (value === null), you want to save that token, I would suggest a helper collection, Publish those tokens by userId who is logged in:

Then call the token unregister method like:

Push.push.unregister(successCallback, errorCallback);