Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Messaging Auth Tokens vs Registration Token

Is there a difference between the firebase.auth().getToken() and the FCM registration token returned via Android setup: FirebaseInstanceId.getInstance().getToken()? I am currently using https://www.npmjs.com/package/firebase which uses the first method above to setup auth as well as generate a token. Using that token when trying to send a notification returns: error:InvalidRegistration...

like image 823
studiobrain Avatar asked Aug 26 '16 01:08

studiobrain


1 Answers

The Auth and FCM tokens are different and unrelated.

The Firebase Authentication ID token identifies the user. A Firebase Authentication access token (auto-generated based on the ID token) grants the user temporary access to the Firebase back-end.

Firebase FirebaseInstanceId token (that is used by Firebase Cloud Messaging) identifies the installation of the app on a specific device.

For example: if you sign in to an app on two different devices, you will get the same authentication UID (although the access token will be different, each time you sign in on a device).

If you have the same app on two devices, the FCM token will be different. But if the app has sign-in functionality, the FCM token will be the same no matter who (or even if) a user is signed in or not. Furthermore: if a different user signs in to the same installed app, the FCM token will remain unchanged.

like image 153
Frank van Puffelen Avatar answered Oct 03 '22 00:10

Frank van Puffelen