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

标签 android push-notification xmpp google-cloud-messaging mqtt

我的用例:登录到我的应用程序的用户应该能够向在另一台 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/

相关文章:

ios - 如果用户拒绝推送通知提示的回调方法?

收到 iOS 推送通知,但不会在设备上显示。铁路,休斯顿

php - 向现有 ssl 证书添加额外端口

ios - XMPPRoster 不会将新好友发布到 XMPP 服务器

java - (Android)我的简单抽屉导航 fragment 不起作用 - 请参阅错误图片

android - 以编程方式在 sqlite 数据库中搜索最佳匹配?

android - Assets 中文件的URI

android - 是否有可能有一个不在标签栏中的 fragment ?

javascript - 仅限内部应用程序的基于“Web”的推送通知

java - 向组内的所有用户发送消息 - Smack API