本文介绍了Firebase 云消息传递身份验证令牌与注册令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

firebase.auth().getToken() 和通过 Android 设置返回的 FCM 注册令牌有区别吗:FirebaseInstanceId.getInstance().getToken()?我目前正在使用 https://www.npmjs.com/package/firebase 它使用第一个上面的方法设置身份验证以及生成令牌.尝试发送通知时使用该令牌返回:error:InvalidRegistration...

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...

推荐答案

Auth 和 FCM 令牌不同且不相关.

The Auth and FCM tokens are different and unrelated.

Firebase 身份验证 ID 令牌用于识别用户.Firebase 身份验证访问令牌(根据 ID 令牌自动生成)授予用户对 Firebase 后端的临时访问权限.

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 令牌(由 Firebase Cloud Messaging 使用)标识应用在特定设备上的安装.

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

例如:如果您在两台不同的设备上登录一个应用程序,您将获得相同的身份验证 UID(尽管访问令牌会有所不同,每次您在一台设备上登录时).

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).

如果您在两台设备上使用相同的应用程序,则 FCM 令牌会有所不同.但是,如果应用程序具有登录功能,则无论用户是谁(甚至是否)登录,FCM 令牌都是相同的.此外:如果不同的用户登录同一个已安装的应用,FCM 令牌将保持不变.

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.

这篇关于Firebase 云消息传递身份验证令牌与注册令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 15:43