How to implement MQTT in this particular usecase of Android?

老子叫甜甜 提交于 2019-12-07 13:37:09

问题


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:

  1. 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.

  2. 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?


回答1:


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.


来源:https://stackoverflow.com/questions/17073229/how-to-implement-mqtt-in-this-particular-usecase-of-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!