简体   繁体   English

如何向FCM(Firebase云消息传递)令牌的特定用户发送消息?

[英]How to send a message to a specific user of an FCM (Firebase Cloud Messaging) token?

The issue is that FCM provides a token for each unique app for a device, so let's say two users use the same device and application, one signs out so that the other can sign in and use the app, i'm confused about how the flow should go! 问题在于, FCM为设备的每个唯一应用程序提供令牌,因此,假设有两个用户使用相同的设备和应用程序,一个用户退出以便另一个用户可以登录并使用该应用程序,我对如何流应该去! now the two users have the same token so both of them will receive the upcoming messages. 现在,这两个用户具有相同的令牌,因此他们两个都将收到即将到来的消息。

A similar question was asked here and here but it's still not clear for me! 在这里这里都提出类似的问题,但对我来说仍然不清楚!

Any help will be appreciated. 任何帮助将不胜感激。

Generate a user specific unique code to each user by yourself at the time of login.send the user specific unique code along with the push notification from server end. 登录时由您自己为每个用户生成user specific unique codeuser specific unique codeuser specific unique codeuser specific unique code以及来自服务器端的推送通知一起发送。

Now send push notifications to all users.and when notification receives check check the user specific unique code to identify the user 现在向所有user specific unique code发送推送通知。当收到通知时,检查user specific unique code以识别用户

When the App is killed, then by default Android will shows the 'notification data' as Notification , So the 'notification data' should be common to all users. 当应用被终止时,默认情况下, Android将显示“通知数据”为Notification ,因此“通知数据”应为所有用户所共有。

User specific data should be added as 'data message'.When a push notification arrives, the default Notification will be shown.And the 'data message' will get through the Intent in the launcher activity.Here you can identify the user by the user specific unique code and respond to push notification. 用户特定的数据应作为``数据消息''添加。当推送通知到达时,将显示默认的Notification。并且``数据消息''将通过启动器活动中的Intent获取。在此您可以通过user specific unique code标识user specific unique code并响应推送通知。

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

相关问题 调用“ https://fcm.googleapis.com/fcm/send”时,Firebase云消息传递出现内部服务器错误 - Firebase cloud messaging getting internal server error when calling “https://fcm.googleapis.com/fcm/send” addCompleteListener()尚未解决-Firebase Cloud Messaging(FCM) - addCompleteListener() is not being resolved - Firebase Cloud Messaging (FCM) MismatchSenderId错误Firebase云消息传递(FCM) - MismatchSenderId error Firebase Cloud Messaging (FCM) Firebase Cloud Messaging(FCM)无法获取数据 - Firebase Cloud Messaging (FCM) not getting data FCM Cloud Messaging 与 Notifications 和 Message 的区别 - FCM Cloud Messaging difference from Notifications and Message 如何使用Firebase Cloud Messaging根据Firebase数据发送通知 - How to send notifications depending on the Firebase data using Firebase Cloud Messaging 在Firebase Cloud Messaging上检查新通知。 (FCM) - Check for new notifications on Firebase Cloud Messaging. (FCM) '发送消息'Firebase云消息传递服务时出错 - 'Error sending message' Firebase Cloud Messaging Service Google Cloud Messaging:向“所有”用户发送消息 - Google Cloud Messaging: Send message to “all” users 虽然我发送了Acknowledge,但Firebase Cloud Messaging会多次发送上游消息 - Firebase Cloud Messaging sends upstream message multiple times, although I send Acknowledge
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM