Cleaning up expoTokens from database

Environment: [Expo Managed Flow: SDK 38]

Hi there,

I am storing expoTokens from users whenever they first open my app in my database table named tokens, I update user’s token with user id later if they decide to sign up or login using their credentials.

I have seen a couple of scenarios please read carefully and please let me know when to delete a token from the database:

  1. user reinstalls app on android, new token generates (I would like to delete old token because sending notification to that old token returns error from FCM and the cause is developer, so this one is clear)

  2. user reinstall app on iOS, new token generates (Sending notification to old token generates no error, status comes back ok, but of course notification doesn’t deliver to old token it delivers to new token though)

  3. user resets Android phone (I tested with factory reset on Samsung), new token generates (Sending notification to old token generates no error, status comes back ok)

  4. didn’t test reseting iPhone

I want to delete expired old useless tokens from the database for obvious reasons, please help me figuring out when to delete those tokens, only case where i could get an error from FCM that is clear that I can delete those tokens from database.

Thanks & Regards, please ask if any questions.