1
votes

I am currently working on a cloud backend for a typical mobile application. The backend is supposed to serve some data and provide notifications on the changes in the backend.

The most common solution for request/response APIs seems to be HTTP REST. The implementation seems pretty straightforward.

Now the question is on the reverse side of the communication flow, i.e. notifications / events from the backend to the application. I'm wondering what kind of protocols and APIs are typically used in modern mobile applications.

From my experience on web applications I'd try WebSockets, possibly STOMP over WebSockets. There are also some other bidirectional protocols like MQTT but I'm not sure it would be a good fit. Such communication could also be implemented with HTTP via polling but I guess it's a dead end, for a number of reasons.

What protocol would you suggest for the kind of communication where the data is pushed from the backend to the application in form of notifications / events?

2

2 Answers

1
votes

I assume you are setting aside Apple Push Notification (APN) for Apple's devices and Google Cloud Messaging (GCM) for Android devices. These are options you can consider.

If you want to implement it by yourself, the main problem, you already know it, is the NAT devices and Firewalls. The options I can come up with:

  • Websockets is one possibility. Always over SSL, otherwise you will have problems with proxies and any other device in the middle.
  • MQTT is an option being considered in IoT. It might be a problem passing through Firewalls but I'm not sure
  • An HTTP option would be COMET and long polling

There are also many services that provide a notification service, like Urban Airship and many others.

0
votes

STOMP is a pretty decent solution. I am not really sure if it fits your use case but if it was me, I would explore it.