gpt4 book ai didi

android - 如何在这个特定的 Android 用例中实现 MQTT?

转载 作者:太空狗 更新时间:2023-10-29 13:29:44 25 4
gpt4 key购买 nike

我的用例:登录到我的应用程序的用户应该能够向在另一台 Android 设备上登录到该应用程序的自己发送消息。如果用户有多个设备,那么一旦他打开消息,其他设备上的通知必须消失。

疑问:

  1. 如何跨设备向特定用户发送数据?我了解如何使用 GCM 向不同设备上的不同用户发送消息,但这似乎相当困惑。

  2. 如何在具有足够安全性的 MQTT 中实现这一目标?我尽可能多地阅读了有关安全性的信息,并得出结论,MQTT 不负责它,我必须在代理级别实现我自己的安全措施。截至目前,Mosquitto 代理允许用户名/密码身份验证,但对于实现 Oauth 的应用程序,用户名/密码似乎相当脆弱。

或者我应该转向 XMPP 吗?

最佳答案

您可以使用新的 User Notifications GCM 的特点。

What are User Notifications?

Third party servers can send a single message to multiple instance of an app running on devices owned by a single user. This feature is called user notifications. User notifications make it possible for every app instance that a user owns to reflect the latest messaging state. For example:

  • If a message has been handled on one device, the GCM message on the other devices are dismissed. For example, if a user has handled a calendar notification on one device, the notification will go away on the user's other devices.
  • If a message has not been delivered yet to a device and but it has been handled, the GCM server removes it from the unsent queue for the other devices.
  • Likewise, a device can send messages to the notification_key, which is the token that GCM uses to fan out notifications to all devices whose registration IDs are associated with the key.

关于android - 如何在这个特定的 Android 用例中实现 MQTT?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17073229/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com