Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FCM Priority vs Delivery Time Clarification Needed

I am currently using the legacy http API to send data messages from my server to Android devices connected to certain topics. I have both, time critical and not so critical messaging. However I never have messaging which needs to wake up attached phones.

So I started with priority=normal, as I expected the behaviour explained here:

https://firebase.google.com/docs/cloud-messaging/concept-options enter image description here

But what I actually observe is more like what is being described here:

https://firebase.google.com/docs/cloud-messaging/http-server-ref enter image description here

When I switch to priority=high messages arrive like instant indeed.

So it seems like the first piece of Firebase documentation is wrong? Or how do I need to proceed to achieve the behavior described there, cause that is, what I'd actually needed in my use case?

BTW I use time_to_live=0 messages in such cases. Messages are small, less than 50 bytes of data.

like image 768
InI4 Avatar asked Apr 02 '26 22:04

InI4


1 Answers

You need to use priority= high like this for example:

const options = {
priority: "high",
timeToLive: 60 * 60 * 24
};

If you want instant notifications when device is in background or shutdown then you need to use priority: "high" since it means that the notification that is sent will have higher priority thus appearing instantly and waking the device.

FCM attempts to deliver high priority messages immediately, allowing the FCM service to wake a sleeping device when necessary and to run some limited processing (including very limited network access). High priority messages generally should result in user interaction with your app. If FCM detects a pattern in which they don't, your messages may be de-prioritized.

timetolive:

This parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline. The maximum time to live supported is 4 weeks, and the default value is 4 weeks. For more information

like image 174
Peter Haddad Avatar answered Apr 09 '26 03:04

Peter Haddad