Firebase Messaging FCM Distribution over configurable time interval - android

When you use FCM to send a push to all devices of a given app this can result in many users opening their apps at the same time which can lead to massive server polling resulting in load peaks.
Is there a convenient way to distribute a message over a given time interval for scheduled pushes?

Finally we found a possible way to archive the goal of a time based distribution by defining pseudo-random topics with a given range.
As an example the app calculates a random integer number between 0 and 9 and uses it as a postfix for a randomized segmentation ("segment_0" to "segment_9"). Now you can distribute the push by sending pushes to the defined segments programmatically or using the Firbase Console over a given timespan.

There is nothing built in that I know of to cause some pseudo-random distribution of delivery. But here are some options I can think of:
From the Firebase console you can schedule the message to be delivered in the user's timezone. If you have a global audience, this means the delivery of the messages will be spread out globally.
Through the API you can delivery a data-only message with the information. This message type is not automatically displayed by the system, but always delivered by your application code. your code can then hold the message and display it after a random delay.

Related

Is it possible to send push notification using firebase console to all user uniformly over a given period of time?

I am using google firebase tool to send push notification to all users at once. Because of this, all notifications reach the user at the same time and it causes momentarily spike in the number of the API request. Normally my backend system handles around 1K requests per minute but during notification, I am getting 40K request at once.
So Instead of sending a notification to all users at once, I want to distribute uniformly over period of 10 minutes. But I do not find any solutions in the firebase. Please help.

Push notifications for a large number of devices

I am pretty new in the push notifications issue, i want to develop an application
for both android and IOS devices, the application should be able to receive real-time push notifications.
The number of users for this app may reach more than 1,000,000 users, i am searching for a good tool for push-notifications.
The most important thing i am concerned of when sending notifications is low-latency, i want to reach a large number of users as fast as possible.
I saw that the service of Google cloud messaging is limited to 1000 users for each request. and any number of users that exceeds this number is sent with batches of 1000, does this effect the speed?
If yes, do you suggest a good push-notifications tool for that purpose?
I would suggest you to use
OneSignal
Best and easy to use API of GCM for Android and IOS and much more. This will fulfill all your requirements
We use GCM with our application.
With GCM one notification can send only to 1000 devices (GCM limit). So you must split your array of devices.
For fastest delivery of Notifications: 1. delay_while_idle - set to false 2. time_to_live - set to zero (But you might want to set this higher if their device is offline) 3. Canonical IDs - Make sure Canonical IDs returned by GCM replace the old PushID in database 4. collapse_key - The most important factor - set it to random or TOD to avoid Google to throttle notifications.
I also recommend
airbop (Android Only)
Pushy

What is a good time between synchronizing jobs?

After discovering that WhatsApp probably updates notifications about every second I began to wonder what the best combination of battery life and keeping users up to date by notifications is.
The company where I work right now is really afraid of sucking the battery life. So they want the fastest sync to be around a quarter. Meanwhile WhatsApp updates every second. So is what our company doing the right thing? Or can we just like WhatsApp check for new updates every second because it doesn't suck that much battery life?
That extensive network usage will surely be very expensive for battery and even for data usage. If you need frequently updated data in your app, in most of the cases it's a bad practice to send HTTP request once per 1 (2 or even 5) seconds.
A good way to receive and update any kind of notification (wether it's Android system notification or some notification badge inside your app) is using Google Cloud Messaging. You'll have to implement it on both server and client side. You will need to register your app package name in Google Developer Console and retrieve an API key. After you do that, your app will be able to receive push notification from GCM server. The flow of receiving a push notification looks like this:
You register current device to GCM system using provided SDK and it generates you GCM unique identifier of current device
You upload this key to your server (if you have user profiles in your app architecture, it's a good idea to store it in current user profile)
Once something important happens on server, say, user gets a new unread message, your server takes the GCM unique identifier from user profile and sends a notification to GCM server
GCM server sends this data to user's device by using this identifier and delivers the notification to your implementation of a BroadcastReciever. After that it's up to you what to do with this data: create a system notification or/and use this information to update UI of your app.
It is just an overview of how does Google Cloud Messaging work, there are tons of articles about how to set it up and implement into your project, for example, this one. This solution might look way more complicated than just sending HTTP request every second, but your potential users will be thankful for saved battery and data limit.
Also, if you want to make Android system notifications, you may want to use Parse library which wraps GCM and makes implementation a bit easier.

Google Cloud Messaging - storing limitations

I developed an app that allows to see or download some files from my VPS. Every day, I'm adding new files (one or two times per day) and I want to notify my users, that there are new files available.
I heard about Google Cloud Messaging, but there is a limit - only 100 messages can be stored. But I think that I get it wrong. This is 100 messages per one device or 100 messages in GCM server?
So far I have more than 8000 active users and I am afraid that some of them will not get notification.
Note: There is a limit on how many messages can be stored without collapsing. That limit is currently 100. If the limit is reached, all stored messages are discarded. Then when the device is back online, it receives a special message indicating that the limit was reached. The application can then handle the situation properly, typically by requesting a full sync.
The 100 message limit is per device and not per application. So if you send 100 messages from your app to a specific device which is offline then all 100 will be dropped.
If I am sending out a message to a few thousand devices, it is expected at least 100 of them to be (temporarily) offline. It doesn't make sense discarding the whole batch.
Google Cloud Messaging

what to include in the C2DM collapse_key filed

I'm implementing C2DM on my android push application, this is what google said about collapse_key:
"An arbitrary string that is used to collapse a group of like messages when the device is offline, so that only the last message gets sent to the client. This is intended to avoid sending too many messages to the phone when it comes back online. Note that since there is no guarantee of the order in which messages get sent, the "last" message may not actually be the last message sent by the application server. Required."
I was wondering what if i want to get all the push sent during the device offline, what should i have in the collapse_key and how can i do that?
I think you should then make a new/different collaps-key for every message. You could just have an integer that keeps getting bigger over time or you could just use the system time...
While CD2M was deprecreated in favor for GCM, take into account that at least GCM allows to have only 4 collapse keys
GCM allows a maximum of 4 different collapse keys to be used by the
GCM server at any given time. In other words, the GCM server can
simultaneously store 4 different send-to-sync messages, each with a
different collapse key. If you exceed this number GCM will only keep 4
collapse keys, with no guarantees about which ones they will be.

Categories

Resources