Skip to content

Commit 7126776

Browse files
authored
Updated comments for more clarity on when onNewToken is called (#1242)
Given the lengthy history of obtaining the token from C2DM, GCM, FCM, and the transition from InstanceID to Installation SDK, added additional clarity to outline all the known scenarios onNewToken is called to match with the details from https://firebase.google.com/docs/cloud-messaging/android/client#sample-register
1 parent 0c39fb9 commit 7126776

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

messaging/app/src/main/java/com/google/firebase/quickstart/fcm/java/MyFirebaseMessagingService.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,13 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
104104

105105
// [START on_new_token]
106106
/**
107-
* Called if FCM registration token is updated. This may occur if the security of
108-
* the previous token had been compromised. Note that this is called when the
109-
* FCM registration token is initially generated so this is where you would retrieve
110-
* the token.
107+
* There are two scenarios when onNewToken is called:
108+
* 1) When a new token is generated on initial app startup
109+
* 2) Whenever an existing token is changed
110+
* Under #2, there are three scenarios when the existing token is changed:
111+
* A) App is restored to a new device
112+
* B) User uninstalls/reinstalls the app
113+
* C) User clears app data
111114
*/
112115
@Override
113116
public void onNewToken(String token) {

0 commit comments

Comments
 (0)