I am developing a mobile application using react native with the help of Expo. I got asked to integrate push notification into the app so I looked it up and followed this guideline for the setups and configurations on the client-side.

Next, I tried to deal with the token generated from the client-side and save it to the database so the server can use the token as the address to send a notification to the device assigned to it and according to the answer from expo team to this forum, " With a Expo, the Expo push token never changes for as long as an app is installed. If the user uninstalls and reinstalls an app they will get a new Expo push token.....".

So I want to know How can we figure out if the an app is installed/reinstalled on a particular device? so expo could gen/regen ExoPushToken for the device. any libraries or snippets to carry this problem out ?

My workaround for now is to generate a new push token whenever the user logins to their account with their username and password (I have pinscreen enabled so they don't have to use their username and password every time they'd like to access their data).

It works but not an effective solution (,I guess). Any ideas? thanks!

1

There are 1 best solutions below

0
On

There are ways to do an action when the app is uninstalled as described in this answer Can I catch an event when application is uninstalled in React Native?

Using this method you can remove the token from the database and on login if the user does not have the token send a new one.

My personal opinion is that you could do it on every login request anyway but if for some reason you do not want to do that maybe this scenario is good enough for you?