0

I'm building an Android app and managed to set up Firebase Instance Messaging in my app. Howerver, I realize that when I open my app again after 5-6 days without open it, the token renewed/refreshed. And I pretty sure I didn't do any of following (based on FCM documentation):

*The app is restored on a new device.
*The user uninstalls/reinstall the app.
*The user clears app data.

But I'm not sure how is this really being done (by the app itself):

*The app deletes Instance ID.

Anyway, is that the new registration token is refreshed only after the app is relaunch (i.e. launched after 5-6 days like my case)?
Would the old token is still workable in receive push notification / instance cloud messaging before the app relaunch (i.e. trigger the onTokenRefresh() ) ?
Or is it the onTokenRefresh() could be even silently running at the background?

So, I'm wondering how those expert chatting apps cater for this kind of scenario? Thanks.

AL.
  • 36,815
  • 10
  • 142
  • 281
elliotching
  • 972
  • 1
  • 10
  • 33

1 Answers1

0

AFAIK, the app doesn't delete the Instance ID on it's own, unless you explicitly call it (see my answer here).

If onTokenRefresh() is triggered, is is the developer's responsibility to call getToken() to retrieve the new and valid Registration Token, send it to their App Server and delete the old one. As stated in the docs:

After you've obtained the token, you can send it to your app server and store it using your preferred method.

onTokenRefresh() can be triggered regardless if the app is in foreground or background (see my answer here). This answer by @DiegoGiorgini has an excellent explanation on how it works.

Community
  • 1
  • 1
AL.
  • 36,815
  • 10
  • 142
  • 281