Mqtt and Push notifications

mike vorisis picture mike vorisis · Feb 9, 2017 · Viewed 11.6k times · Source

I have made an app for ios devices that can connect to a mqtt broker and send and receive messages when the app is in the front or background state.

Now I want to archive to receive messages even if I terminate the app from the background state.

I believe pushy is a very good documented service so I was looking at this and its backend tutorial.

For my broker I use hivemq and my question now is, can I modify the code that uses to send messages with that the pushy has? Or maybe could I use another broker more flexible?

To sum up I want to know how can I setup my broker to send push notifications (hivemq or anything else more customizable)

Any documentation will be great

Thanks in advance.

Answer

Pavel Zdenek picture Pavel Zdenek · Feb 9, 2017

A push notification on iOS/Android is generally capable of waking up or even starting the target app from scratch. As compared to MQTT, where an app can receive a message only when it's started and subscribed to the broker. Push notifications are very special and very different kind of message. The fact the one particular push notification service uses MQTT for its transport does not mean that you could do the same. Well, unless you want to code such full blown service yourself. You cannot really do it just with a "more customizable MQTT broker" - MQTT broker can't make your app to start up.

Plus, Pushy uses MQTT only for Android, because on Android, one can reportedly fake the official GCM/FCM push backend - and it's apparently not easy because majority of services just piggybacks on GCM/FCM. On iOS, you are inescapably dependent on the official APNS and even Pushy must use it - no MQTT push on iOS.