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

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

问题描述

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

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天全站免登陆