Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FCM push with high priority to topic comes with delay

I'm sending push messages to small group of devices (less than 5) subscribed to one topic with priority parameter set to high

High priority. FCM attempts to deliver high priority messages immediately, allowing the FCM service to wake a sleeping device when possible and open a network connection to your app server. Apps with instant messaging, chat, or voice call alerts, for example, generally need to open a network connection and make sure FCM delivers the message to the device without delay. Set high priority only if the message is time-critical and requires the user's immediate interaction, but beware that setting your messages to high priority contributes more to battery drain compared with normal priority messages.

But when I put device to IDLE state it comes with big delay. On Nougat 7.1 delay is more than 10 mins. This type of push requires delay less than 10 secs.

Setting time_to_live to 0 solves issues only on Marshmallow. Nougat still failing.

So, I see only 3 possible causes of issue

  1. Messages sent to topic can't be high priority. But sending independent messages to each device will increase app-server load. I need to load fresh token from Firebase Database, so the result will be - 10 http requests for 5 users instead of 1.

  2. App must be in whitelist. But according to docs it's not acceptable, if I'm using FCM. And I don't want it, because it will cause battery drain.

  3. Bug? https://github.com/firebase/quickstart-android/issues/100

If real cause is first, then why it isn't described in documentation?

like image 856
Dima Rostopira Avatar asked Nov 14 '16 13:11

Dima Rostopira


People also ask

Why is FCM delayed?

This could be caused by the unrealistic heartbeat intervals in Firebase Cloud Messaging. FCM works by maintaining an idle socket connection from an Android device to Google's servers.

Is there a limit for firebase push notification?

Notification messages can contain an optional data payload. Maximum payload for both message types is 4000 bytes, except when sending messages from the Firebase console, which enforces a 1024 character limit.

How does FCM push notification work?

Using FCM, you can notify a client app that new email or other data is available to sync. You can send notification messages to drive user re-engagement and retention. For use cases such as instant messaging, a message can transfer a payload of up to 4000 bytes to a client app.


1 Answers

Issue solved by setting time_to_live to 0. According to docs, this set's priority to "now or never"

Another advantage of specifying the lifespan of a message is that FCM never throttles messages with a time_to_live (TTL) value of 0 seconds. In other words, FCM guarantees best effort for messages that must be delivered "now or never." Keep in mind that a time_to_live value of 0 means messages that can't be delivered immediately are discarded. However, because such messages are never stored, this provides the best latency for sending notification messages.

UPD: solved only for Marshmallow. On Nougat is still an issue.

UPD2: just don't use topics, they aren't intended for sending pushes without delay.

like image 128
Dima Rostopira Avatar answered Oct 13 '22 02:10

Dima Rostopira