Firebase push notification delay after triggering few high priority notifications - android

I use Firebase high priority push notifications to trigger Panic alarms in Android devices. For first few tries of push, immediately push notifications arrives and it works great. But when i keep triggering push notifications after certain amount of time slowly delay keeps increasing.
I want it to trigger immediately as it is Panic situation.
I also followed the documentation which read:
High priority: 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 or its notifications. If FCM detects a pattern in which they don't, your messages may be de-prioritized. Android P introduced app standby buckets which limit the number of FCM high priority messages you can send to your app that don't result in the user using your app or viewing a notification. If, in response to a high priority message, a notification is displayed in a way that is visible to the user, then your app standby bucket quota will not be consumed by that message.
Because a small portion of the Android mobile population are on high latency networks, avoid opening a connection to your servers before displaying a notification. Calling back to the server before the end of the allowed processing time may be risky for users on high latency networks. Instead, include the notification content in the FCM message and display it immediately. If you need to sync for additional in-app content on Android, you can schedule an FJD job or a JobIntentService to handle that in the background.
How can I make sure high priority messages are triggered as soon as possible? May be within a minute in all cases.

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 or its notifications. If FCM detects a pattern (such as testing pattern) then your messages may be de-prioritized. Android P introduced app standby buckets which limit the number of FCM high priority messages you can send to your app that don't result in the user using your app or viewing a notification. If, in response to a high priority message, a notification is displayed in a way that is visible to the user, then your app standby bucket quota will not be consumed by that message.

Related

FCM: Is data message delivery really less reliable than notification message delivery?

Question
I have come across some voices stating that FCM data message delivery is less consistent compared to that of notification messages. Does anyone have direct experience or can point me to resources exploring the issue? Or is a notification message just a collapsible, high-priority data message that the Firebase SDK handles automatically?
https://stackoverflow.com/a/49998176
FCM data message not received in Android when the application is in background
About FCM's notification message and data message type, which has better receiving rate
The question does not consider the case of force quitting the app. In this scenario, both types of messages will not be delivered (to my knowledge).
Background
I am writing a new Android SDK for a push service provider (similar to OneSignal). The SDK should handle the display of push notifications by default, optionally the client app can handle incoming pushes itself.
The actual delivery is of course done by Firebase Cloud Messaging (on devices running Play Services). So there are 2 types of messages to choose from on FCM: data vs notification messages.
As data messages are consistently handled by the registered FirebaseMessagingService (provided there is no notification key in the payload), this should be the way to go for the SDK. [See documentation] So far, I have not been able to produce a situation in which a data message was not delivered (foreground or background).
By setting the priority in Message, We can reflect the delivery.
You have two options for assigning delivery priority to downstream messages on Android: normal and high priority. Delivery of normal and high priority messages works like this:
Normal priority. This is the default priority for data messages. Normal priority messages are delivered immediately when the device is not sleeping. When the device is in Doze mode, delivery may be delayed to conserve battery until the device exits doze. For less time-sensitive messages, such as notifications of new email, keeping your UI in sync, or syncing app data in the background, choose normal delivery priority.
When receiving a normal priority message on Android that requests a background data sync for your app, you can schedule a task with WorkManager to handle it when the network is available.
High priority. FCM attempts to deliver high priority messages immediately, allowing FCM 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 or its notifications.
See Set and manage message priority topic in FireBase Documentation.
For More details you can prefer this link
For Displaying the Notification You Can Prefer this link
Best Of Luck In Advance.

Firebase high priority message when app is on foreground

I am using FCM messages on my android project. I have read this info on developer page;
High priority messages on Android are meant for time sensitive, user visible content, and should result in user-facing notifications. If FCM detects a pattern in which messages do not result in user-facing notifications, your messages may be deprioritized to normal priority.
I just want know , must we show user-facing notifications even if app is on foreground? if we do not show notification when app is on foreground (any activity is visible) May it cause any deprioritization?

About FCM's notification message and data message type, which has better receiving rate

We are choosing to use FCM's notification message or data message (only for custom designs). We already know that custom designs data message perform better than the non custom design data messages. But we are wondering if notification message can have better receive rate than data message because it is using the system to show the notification. Anyone has done any investigation?
If not, then what's the advantages the notification message type have
It's an interesting question and topic of research. I faced the same
the situation about a while ago.
According to firebase's documentation :
Notification messages are high priority by default, and
collapsible--the following message will replace the current message if
it's not delivered yet.
In the custom data type payload, you can actually pass the notification priority to high. But.....
According to this document from firebase
High priority. 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 or its notifications. If FCM detects a
pattern in which they don't, your messages may be de-prioritized.
Android P introduced app standby buckets which limit the number of FCM
high priority messages you can send to your app that don't result in
the user using your app or viewing a notification. If in response to
a high priority message, a notification is displayed in a way that is
visible to the user, then your app standby bucket quota will not be
consumed by that message.
And now let's talk about my personal experience. I faced the same
situation and the observations we noted with our QA were quite the
same as their documentation.
Although after setting priority HIGH in data type payload we noticed random behaviour with some custom OS phones like Oneplus, Oppo etc. While in the case of notification type payload it was consistent and we were getting notification perfectly.
So I advise that if you don't have a particular requirement to handle
the data silently in the background just go with a simple
notification payload.

Do notifications while the screen is off prevent an FCM High Priority message from counting against the "App Standby Bucket"

I'm working on a messaging app where messages need to come through so we're sending our messages as "High Priority" to bypass Doze.
In Android P they added a new thing called "App Standby Buckets" which limit how many FCM messages you can send if the app isn't in the "active" or "working set" app list.
The buckets are detailed at this link
https://developer.android.com/about/versions/pie/power
The documentation also says
If, in response to a high priority message, a notification is
displayed in a way that is visible to the user, then your app standby
bucket quota will not be consumed by that message.
If the screen is off and the notification sound plays, but the user doesn't see or interact with the notification since the screen is off, will that count against our bucket limit?
These notifications need to come through and being placed in the frequent or rare bucket could be very problematic.
I know we can request permission to bypass battery optimizations (I believe we fall in the allowed category) but there's no guarantees that will be granted.

Android: How many times can I send a high priority GCM to my app in Android 7.0?

I have an android app and I am using GCM. I will upgrade it to FCM. But for now, How many times can I send high priority GCM, or for the sake of it FCM so that it can do some network requests in an hour.
If you are referring to Downstream messages, there is no limit on how many messages you could send regardless of it's priority.
I noticed that you added the android-doze tag in your question. For some devices, it is possible that some requests will be postponed or dropped until such time that the app exits doze mode, similarly to what happens when the app is in background and/or killed state (see here).

Categories

Resources