FCM(firebase 云消息传递)令牌是用于一台设备还是一个帐户? [英] Is FCM (firebase cloud messaging) Token for one device or for one account?

查看:17
本文介绍了FCM(firebase 云消息传递)令牌是用于一台设备还是一个帐户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户注册到应用程序时,我想将 FCM 令牌存储在数据库中的我的 android 应用程序用户表中.当我想向特定用户发送通知时,我将从相应行获取令牌并发送推送通知.但我很困惑,每当应用程序用户从他的应用程序注销并从同一设备注册新帐户时,就会有两行,因此数据库上同一设备的两个令牌.如何处理这种情况?设备中的旧 Token 会怎样?请任何人都可以帮助我?

I want to store FCM token in my android app user's table in database when user register to the app . When i want to send notification to specific user then i will fetch Token from corresponding row and send push notification.But i am confused that whenever app user logout from his app and register new account from same device ,then there will be two row and hence two Token for same device on database. How to handle such case? What happen to old Token in device? please anyone can help me??

推荐答案

用于发送 FCM 消息的实例 ID 令牌代表设备上的实例和应用程序.应用程序的当前用户不会影响代表应用程序实例的令牌.卸载并重新安装应用程序会导致生成新令牌,但不会用于切换用户等应用程序内行为.

The Instance ID token used to send FCM messages represents the instance of and app on a device. The current user of the app would not affect the token that represents the app instance. Uninstalling and reinstalling the app would cause a new token to be generated but not for in app behaviour like switching users.

您仍应在注销时删除令牌到用户的映射,并向登录的用户添加具有相同令牌的新映射,但它将是相同的令牌.

You should still remove the mapping of the token to the user on logout and add a new mapping with the same token to the user that logs in but it will be the same token.

这篇关于FCM(firebase 云消息传递)令牌是用于一台设备还是一个帐户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆