How can I reliably revoke (delete from the user profile on my server) device token for users of my service when they exit my application?
I save an array of strings containing apns tokens in my user profiles, adding them every time the user allows push notifications on this device.
Later I realized that the push token is unique to the device, but obviously does not know anything about my internal user accounts, so if one user logs out and another log (one device), each of them has one and the same same token. Then, the current device user receives push notifications directed to any of them.
The main solution is to remove the device token from the user profile when logging out, but I come up with a bunch of gotchas since I think through:
- Logging out does not require network access - I can try to notify my server, but logging out requires asynchronous execution, even if the user does not have network access (?)
- The actual device token may not be known - if the user has temporarily disabled push permission, the current token is not indicated. And information about the stored device β seems insignificant at best, because the ForVendor identifier changes for each installation, and the UDID methods are outdated.
- Destroy on the server side (when adding a token to the account, make sure that the same token is not set for other accounts) - it depends on the second user login to the system, which is not guaranteed.
Are there more cases of edges that I donβt have, and what strategies can I use to work them?
rest ios push-notification apple-push-notifications
owenfi
source share