0

I am generating firebase token using the following line of code

String refreshedToken = FirebaseInstanceId.getInstance().getToken();

I get the token , which I store in the database. I'am able to use this to send notification to individual devices.

But after a few days I get the message as 'Unregistered registration token' and the notification is not delivered.

can you please solve the problem.

Also is there a way to check the validity/registration of a token in firebase console?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

New Firebase token is generated (onTokenRefresh() is called) 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.

Refer this :

Firebase Token

Community
  • 1
  • 1
Ashish
  • 371
  • 3
  • 18
  • But if nothing of the above is done , how long will the firebase token be valid. – Sohan Kumar Nov 25 '16 at 03:49
  • validation of token is about 1 hour.... – Ashish Nov 25 '16 at 03:54
  • you can check using ....public static boolean hasValidAuthToken() { return FirebaseAuth.getInstance().getCurrentUser() != null ? true : false; } – Ashish Nov 25 '16 at 03:55
  • 4
    @Ashish Firebase Authentication tokens are valid for one hours and auto-refresh. But Firebase Cloud Messaging/Instance Id tokens don't have a specific invalidation interval and typically remain valid **much** longer. For a list of the very specific cases when the token is refreshed, see [my answer here](http://stackoverflow.com/questions/40628749/firebase-token-management-in-servers/40632811#40632811) or the [Firebase documentation](https://firebase.google.com/docs/cloud-messaging/android/client#sample-register). – Frank van Puffelen Nov 25 '16 at 04:52