简体   繁体   English

Flutter firebaseMessaging 令牌

[英]Flutter firebaseMessaging token

await FirebaseMessaging.instance.getToken();等待 FirebaseMessaging.instance.getToken();

I used this code to get token but apparently this code just give me the token of the device, For example, if i uses many accounts in my app, i'll get the same token for every accounts.我使用此代码获取令牌,但显然此代码只是给了我设备的令牌,例如,如果我在我的应用程序中使用多个帐户,我将为每个帐户获得相同的令牌。 But if i use another device, i'll get different token.但如果我使用其他设备,我会得到不同的令牌。

A firebase messaging token is tied to an installed App on a device, not to a particular user. Firebase 消息传递令牌与设备上已安装的应用程序相关联,而不是与特定用户相关联。

See: Firebase Cloud Messaging Auth Tokens vs Registration Token请参阅: Firebase 云消息传递身份验证令牌与注册令牌

What is the proper way to capture device registration tokens in order to send notifications via Firebase Cloud Messages? 为了通过 Firebase 云消息发送通知,捕获设备注册令牌的正确方法是什么?

FCM 令牌是根据应用程序、它的捆绑包 ID 和设备生成的,这就是为什么它对于同一应用程序的每个设备都是唯一的。

Flutter firebaseMessaging Token is device specific.If you want to change your token then you can reinstall the app. Flutter firebaseMessaging Token 是特定于设备的。如果要更改令牌,则可以重新安装该应用程序。 If you want token based on user then you can use TokenRefresh method.如果您想要基于用户的令牌,那么您可以使用 TokenRefresh 方法。

The token is generated per the client app instance.令牌是按客户端应用程序实例生成的。

On initial startup of your app, the FCM SDK generates a registration token for the client app instance.在您的应用程序首次启动时,FCM SDK 会为客户端应用程序实例生成一个注册令牌。

See Best practices for FCM registration token management for details.有关详细信息,请参阅FCM 注册令牌管理的最佳实践

Only one user at the time is logged in on the app instance.当时只有一位用户登录应用程序实例。 Delete the token when a user logs out and then you get a new token when a new user logs in.当用户注销时删除令牌,然后在新用户登录时获得新令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM