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:
- 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
- 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
- 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).
- Cordova has a library that abstracts and handles this functionality and exposes it from behind a generic API
- 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?