2

Battle-weary backend developer cutting his teeth with frontend/mobile development here. I'm designing an Angular/Ionic/Cordova app that will ultimately generate an Android APK (which I'll deploy as a hybrid/native-ish app to the Google Play store) as well as an Apple APP (which I'll deploy as a hybrid/native-ish app to the Apple App store).

This app will allow the server to send all connected client apps/devices "notifications". When a client app receives a notification, the frontend code will react to it by displaying a red flag in the top-right corner to the user, visually indicating to the user that they have a new notification. Pretty standard stuff.

I was originally thinking about implementing this solution with something like WebSockets. However after doing some digging it appears that both Android and Apple (and Ionic/Cordova) have a special notification feature/API that they expose for server-side "push" notifications to connected client devices/apps. And my understanding is that they both work pretty similarly, as follows:

  1. Server sends a notification message (I assume this could be any format: JSON, XML, raw text, etc.) to some Android/Apple API over HTTP/REST
  2. Android/Apple servers keep track of connected client devices/apps and send the messages/notifications on to the correct devices either immediately if they're online, or just the next time they are connected/running on the user's devices
  3. Android/Apple SDKs provide some kind of event-driven, reactive hooks that allow the app developer to respond to receiving these notifications anyway they want to (in my case, render a red flag in the top-right corner of the app's screen).
  4. Cordova has a library that abstracts and handles this functionality and exposes it from behind a generic API
  5. AWS SNS somehow supports this architecture w/ the Android/Apple REST APIs

So first, if anything I've asserted above is incorrect or wildly misled, please begin by correcting me!!!

Assuming I'm more or less correct above, I'm interested in understanding why this type of setup is preferred over using plain 'ole WebSockets? Also interested in learning more about the AWS SNS integration capabilities. So I ask: with a hybrid app built on Angular/Ionic/Cordova, what's wrong with server-pushes/WebSockets, and why do I need to use these built-in Android/Apple notification systems?

smeeb
  • 27,777
  • 57
  • 250
  • 447
  • 1
    This is outside my field of expertise but I would suggest that battery power and wireless data consumption are significant factors. It costs nothing extra (in resources) for an app to leverage the official notification model, while homebrew would require that your app be running and connected in the background, eating power and network bandwidth (web sockets, eventsource, etc., need keepalives for reliability). – Michael - sqlbot Dec 16 '17 at 21:35
  • 1
    The question may seem subjective or opinion-based to some, but I would suggest that there are objective reasons to use the standard models for notifications, aside from any more subjective reasons like developmental/management/monitoring complexity or infrastructure requirements, which a back-end person like you or I might more easily dismiss than would someone less experienced with designing and implementing (let alone enjoying) such things. – Michael - sqlbot Dec 16 '17 at 21:37
  • 1
    Thanks @Michael-sqlbot (+1 for both) some very good reasoning there. Any idea what these native platform notification systems are actually called (I couldn't find any by Googling them) and how they integrate w/ AWS SNS? Thanks again! – smeeb Dec 17 '17 at 02:26
  • 1
    Google Cloud Messaging (GCM), Apple Push Notification Service (APNS), Amazon Device Messaging (ADM), and some others can be accessed via SNS. You would probably want to start here: http://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html – Michael - sqlbot Dec 17 '17 at 03:51
  • 1
    I found a similar question [here](https://stackoverflow.com/q/31645010/1695906) but at the moment I am undecided whether to cast a vote to close this one as a duplicate of that one since the other question is GCM specific... but it turns out the answer there is essentially the same as what I speculated, above... battery and bandwidth. – Michael - sqlbot Dec 17 '17 at 04:01

0 Answers0