I’m developing an app and I realized that I ended up with the same push token for two different users.
My app allows logging in with Gmail so I guess I saved a push token in my backend when being logged with 2 different users. Of course this lead to one user receiving data which was destined for the other.
How should I be approaching this?.
Thx in advance
It’s easy: you can’t. Push tokens are by design bound to app + device. You can’t provide something like an user id. The token will always be the same, as long as the OS didn’t update or the app has been reinstalled or any unkown effect happened (remeber: always grab for the token every now and then [i do it on every app start and update it on my server]) The right way is to delete the stored push stoken on your server when your users log out.
Yup, I’m always sending the token on app start as well. I do like the approach of removing the token from the server.
The one caveat I could think of would be when it comes to the same users having multiple devices. I’d have to store the device ID (dunno if that’s allowed) together with the push token that was generated so that I would know which of his, potentially multiple, tokens to delete. But that’s another story I guess.
@hirbod Do you know if there could be any issues (GDPR or such) when saving in the backend the
deviceId value provided by the expo SDK? (as a solution for the approach you mentioned)
You already know the token and the user id - no need to save any deviceId. Watch your push receipts (they have a status endpoint) and delete dead tokens when they are reported.
There is also no reliable UUID on iOS, it can change at anytime and any app update. Bypassing this at any way will get your app deleted on App Store.
Store the token in your AsyncStorage and send it over when the user logs out. As far as I know, Expo won’t change the exponent token when the real device token changes. (At least as long the user is internally identifiable)
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.