We have an app (Ruby on Rails) that sends push notifications to an android app and we're facing an issue with GCM where some of these notifications are either delayed or never received. Considering the fact that these notifications are being sent to employees and not end-users my questions is:
What the best way to send these push notifications without any delay or drop and is there a way to send push notifications independently from the available services such as GCM and SNS?
Please keep in mind that we're looking for a solutions that can send these notifications without any delay as for the app to perform well the notification must be received within 1 to 20 seconds from the time it was sent.
Thanks in advance for anyone that will reply to this question...
Have a look at "Pushy":
They state the following on their website:
The most reliable push notification gateway, perfect for real-time
applications.
Google Cloud Messaging simply doesn't cut it for time-sensitive,
real-time apps, due to its instability and push notification
throttling.
Pushy works by maintaining a dedicated background socket connection
using the MQTT protocol, an extremely light-weight pub/sub protocol
that consumes very little network bandwidth and battery, which makes
it perfect for mobile.
You can use it for free with up to 100 devices, so you could just give it a try to see, if it fits your needs. I didn't try it.
Related
This is an architectural question. I haven't implemented FCM yet, but as far as I understand someone needs to deploy an XMPP server in a real world scenario which provisions the inventory of the registered device tokens.
In my use case I'd like to just broadcast short messages about important update information, like "XY presenter's session at 15:00 got cancelled" and I'm not interested in the device tokens. My application is a Progressive Web App, so I would use FCM for Web.
The demos I saw so far showed a client receiving the device token, then that specific device token was picked up from the debug environment and used to send the demo message to the client - thus bypassing the need of a deployed stand-alone XMPP server, but just for demo purposes.
I'd want to avoid the use of an XMPP server, I'm not interested in dealing with the device tokens at all - if possible. Firebase's FCM/GCM server have them anyway. My plan is to pick a single topic name for that channel (the only topic what my app would use actually at this point), and push messages to the devices who listen to that topic. Is this a viable plan? I haven't found any mention of this whatsoever. Firebase knows all the tokens internally and it would make the architecture simpler if I don't have to deploy a server.
I don't know how the decomission/expiration of the device tokens would happen on Firebase's side, but that's another issue I'd have to deal with if I'll run my own XMPP server and provision tokens.
To send messages to a device (so-called downstream messages), you need to specify the server key. As its name implies, this key should only be present on a server or in some other trusted environment. So to send messages to devices you will need to run code in a trusted environment.
The server doesn't have to speak the XMPP protocol however. You can also just use HTTP to call the FCM servers. But a server will be needed, simply because sending downstream messages can only be done from a server.
For a simple example of sending device-to-device messages with this approach, see my blog post Sending notifications between Android devices with Firebase Database and Cloud Messaging. It's about Android, but the same approach of using the Firebase Database as a message queue will work across all platforms.
The tricky bit to map will be (as you already mention) the fact that topics are not available to FCM for the web yet. Last time I tested, you could call a server-side end-point to subscribe to a topic, like described in this answer: GCM: How do you subscribe a device to a topic?.
I learned that PUSH NOTIFICATION service is like a persistent TCP connection.
But I don't know how maintain the connection even if the phone terminate the app.
In mobile application, if the subscription is destroyed, how we publish and deliver the message?
Should I use GCM, APNS or SMS? And wait until client subscribe the topic?
That's correct, you have to be connected with the broker (mosquitto broker in this case) to receive the push notification (you also must be subscribed to topic).
In Android I'm using paho client libray, a Service for keep connection in background, and BroadcastReceiver to start service at reboot.
For iOS you can find swift and Objetive-C MQTT-client librarys (I'm using CocoaMQTT) but you can't keep connection in background indefinitely. You have to use APNS.
I am trying to understand how exactly push notification services work.
Are these real push services with constant connection to server or just mimics by polling?
How does a server with heavy traffic maintain so many connections?
In general push notifications work both by establishing a long-lived TCP connection, or using long-polling. The maximum number of connected clients is determined by the server resources.
Take a look at the Socket.io protocol stack for an example. Or better yet, at the XMPP/Jabber protocol, which relies on TCP principally and falls back on long polling.
Fusio is correct. For mobile phones, a single push service is typically used (Google cloud messaging for android, Apple Push Notification Service for Apple/iPhone) to limit the amount of connections from the phone. 3rd party applications register to these services and push messages through them.
Without polling how does the Flex application receive push notices?
I assume Tweetdeck didn't do push notifications. I assumed it made API calls on a timer. When I have Tweetdeck and ServiceCapture up at the same time, tweetdeck sure does send a lot of traffic. I assume it is server pings looking for more data to retrieve.
That said, to do push notifications You need a socket server; so that the client is perpetually connected to the server. A few options for servers that support this are Adobe's LiveCycle, BlazeDS, GraniteDS, or WebORB.
I understand that GraniteDS uses a technique called long polling. BlazeDS uses the same approach. LiveCycle--and I believe WebORB--can use RTMP to do push notifications.
What are push notifications and how do they work? Also what is the difference with googles cloud to device messaging? Is c2dm also a push notification? Also do I need Special server setup to implement push notification?are push standard or every device has different implementation?
Basically the server maintains a list of connected clients. Whenever something of interest occurs, the server sends the data/notification/updated state to the connected clients. This is in contrast with pull, where the clients poll the server for changes.