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