'Firebase subscribe to topics not working after reinstalling app

I made an app which was working fine until I found that after deleting and reinstalling the app it doesn't receive messages anymore that are sent to a a topic, although it does receive a message that is sent to the id-token of the app. Does anybody know what might be the problem? Firebase or my app?

Update: After clearing cache and data of the app it can receive notifications again. If reinstalled there's a chance of not working. I have to do some more testing, but I think it is solved by setting android:allowBackup="false" in the app manifest.



Solution 1:[1]

After the uninstall and reinstall, your app on that device was assigned a new device token. According to that documentation:

The registration token may change when:

  • The app deletes Instance ID
  • The app is restored on a new device
  • The user uninstalls/reinstall the app
  • The user clears app data.

That new token won't have all the same subscriptions that the old one had. You'll have to re-subscribe to the topics that the user was interested in on that device.

It's not just reinstalls - your app should be ready to handle new tokens at any time, based on the criteria listed above. The linked documentation illustrates how to listen to token changes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Doug Stevenson