FirebaseMessagingService. onNewToken() method is called even though token is not changed after calling FirebaseInstanceId. getToken() method first time.

4,413 views
Skip to first unread message

Hardik Muliya

unread,
Mar 27, 2019, 10:35:36 AM3/27/19
to Firebase Google Group
Platform: Android.
Feature: Firebase Cloud messaging.

Behavior: 
Whenever FirebaseInstanceId. getToken() method is called very first time, It retrieves a fcm token.
My app sends this token to the server.
After a few seconds, FirebaseMessagingService. onNewToken() method is called even though the token is not updated, it gives the same token.

I don't maintain a copy of token in App's local DB.
Hence whenever FirebaseMessagingService. onNewToken() method is called, App again sends token to the server even though it is actually not updated.

Please note that this behavior happens only first time FirebaseInstanceId. getToken() method is called.
Subsequent call of this method does not led to the invocation of FirebaseMessagingService. onNewToken() method.

FirebaseMessagingService. onNewToken() method is called even though token is not changed after calling FirebaseInstanceId. getToken() method first time.

Any one observed this behavior?
Does this behavior sound like a defect?

Kato Richardson

unread,
Mar 27, 2019, 11:28:36 AM3/27/19
to Firebase Google Group
Hello Hardik,

This sounds unlikely. What is probably happening here is that the token is rotated when the app is initialized and the call to getToken() coincides with obtaining a new token. 

Note the conditions where your token may get updated:
  • The app deletes Instance ID
  • The app is restored on a new device
  • The user uninstalls/reinstall the app
  • The user clears app data.
If you can create a minimal repro that demonstrates that the app already has a valid token, onNewToken() has already been invoked, and then you call getToken() and that results in a new invocation of onNewToken() with the same token id, please report that as a bug here.

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/97a7084d-d193-44bc-921a-d9305535a39d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Reply all
Reply to author
Forward
0 new messages