如何在Android的这个特定用例中实现MQTT?(How to implement MQTT in this particular usecase of Android?)

编程入门 行业动态 更新时间:2024-10-26 21:22:24
如何在Android的这个特定用例中实现MQTT?(How to implement MQTT in this particular usecase of Android?)

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

释疑:

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

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

或者我应该转移到XMPP?

My usecase: A user logged into my app, should be able to send messages to himself logged into the app on another Android device. If the user has more than one devices, then once he opens the message, the notification on other devices must disappear.

Doubts:

How to send data to a particular user across devices? I understand how to send messages to different users on different devices using GCM but this seems rather confusing.

How to achieve this in MQTT with adequate security? I read as much as I could about the security and got to the conclusion that MQTT isn't in the charge of it and that I've to implement my own security measures at the broker level. As of now Mosquitto broker allows username/password authentication, but for an app implementing Oauth, username/password seems rather vulnerable.

Or should I move over to XMPP?

最满意答案

您可以使用GCM的新用户通知功能。

什么是用户通知?

第三方服务器可以将单个消息发送到在单个用户拥有的设备上运行的应用程序的多个实例。 此功能称为用户通知。 用户通知使用户拥有的每个应用实例都可以反映最新的消息传递状态。 例如:

如果在一台设备上处理了消息,则其他设备上的GCM消息将被解除。 例如,如果用户在一台设备上处理了日历通知,则该通知将在用户的其他设备上消失。 如果消息尚未传送到设备但已处理,则GCM服务器将其从其他设备的未发送队列中删除。 同样,设备可以向notification_key发送消息,该消息是GCM用于向其注册ID与密钥相关联的所有设备扇出通知的令牌。

You can use the new User Notifications feature of 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.

更多推荐

本文发布于:2023-07-31 08:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1341912.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   Android   用例中   usecase   implement

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!