When we disable push notifications at app level:
Does the OS automatically unregister the app from GCM/FCM ? (i.e) Will the GCM/FCM stop sending messages to the client for that app.
Will the push event listener code block be executed (minus UI tray) even when push is off at app level ?
Does the OS automatically unregister the app from GCM/FCM ? (i.e) Will the GCM/FCM stop sending messages to the client for that app.
Yes. The GCM/FCM server doesn't determine if the device has disabled notifications for the corresponding app. So long as the device was targeted for the message, GCM/FCM will deliver the message.
Will the push event listener code block be executed (minus UI tray) even when push is off at app level ?
FCM for Android works differently depending the message payload type you sent. However, depending on the device, usually when Notifications are disabled, regardless of notification type, it would be blocked by the OS.
For more infos:
SO post
Received message in Android App
Can Firebase console push notification if apps is closed
Related
My question is about standard remote push notifications on iOS and Android devices when the app is terminated.
In a nutshell:
There are different app states/modes:
Foreground
Background
Suspended
Terminated
There are different notification types:
Normal Notification (contains alert information)
Data/Silent Notification (contains data payload)
Mixed Notification (alert and data)
For foreground, background and suspended mode it is clear and does work very well on iOS and Android. Dependent on the notification type the expected behavior as stated in the docs.
But it seems there is an essential difference in remote notifications for iOS and Android when the app is terminated.
For iOS: If the app is terminated (not suspended) a standard remote notification is received by the iOS system and displayed in the notification center. There is no delegate called and the app is not put to background mode (not even if remote push background mode is enabled). When the user clicks the notification the app is started and the notification object is provided via the appropriate delegate. Summarized: The user can receive push notifications on his device even if the app was force-quitted.
For Android: When the app is terminated a standard remote push notification is not displayed in the notification center. (As soon the app is started and put to the background the notifications are received and displayed properly.
The documentation is very unclear because only foreground and background mode are mentioned.
https://firebase.google.com/docs/cloud-messaging/concept-options
https://firebase.google.com/docs/cloud-messaging/android/receive
There are many discussions that conclude that remote notifications are not displayed in the system tray (notification center) after the app as been force-quitted. But there is quite less discussion about the expected behavior after device restart and not starting the app.
But there are also discussions indicating that remote pushes are always displayed in the system tray, even if the app has been terminated (Android push notifications not being received when app closed). That would be the same behavior as for iOS.
To get to the point: Is it possible on Android to send remote push notification to the device's system tray, even if the app is terminated/force-quitted/not running?
I can answer now my own question: It is possible to send push notifications to Android devices (in the notification center) while the app is not running.
The issue with notifications not being delivered was caused by Huawei's EMUI and specific battery saving settings. On Huawei P8, P9 and probably many other devices with EMUI the apps are not allowed to receive notifications when not running. They must be authorized explicitly in the battery saving settings.
I'm working on a app with FCM (Just use Data payload and set high priority already).
During the test I found that sometimes my device can not receive the message from fcm.
Regardless of app's state (swipe out/killed/force stopped), the message is delivered to the device perfectly when I send the push request to FCM server in a short time after changing the app's state.
But if I waiting for some hours after closing screen, No message can be received.
Is it possible that in os/device level, the messaging service is stopped when the device entering some mode like doze and message delivery is failed?
Is it possible to receive message when the device is deep sleep?
My app server written in GO language is sending notifications to the device through FCM / XMPP. When i set delivery_receipt_requested to true, i am not receiving delivery status message every time.
For testing purposes, i made test app that sends push notification every second with delivery_receipt_requested to true. For 10 notifications, i am receiving only two or three (sometimes not even one) delivery status message, and on android app all notifications are delivered.
I tried two FCM / XMPP Go libraries, but both of them have same behavior (Go-FCM, Soygul GCM)
On android device, latest Google Play Services are used (at the moment 10.2.4)
Is this common behavior, or am i missing something?
I am working on a Cordova Android app that handles push notifications using the PushPlugin. The app will correctly receive push notifications when the app is open. However no push notifications are received (or at least handled) if the app is not open.
This makes some sense given that the plugin has code that specifically handles receiving push notifications. What does not make much sense to me is why this code even exists at all. Before building this app, I assumed that the OS had some sort of queuing system that received any/all notifications.
Does a notification queue exists in Android that handles push notifications for all apps or does each app need to handle the notifications on their own.
Can Android apps process push notifications while closed?
Can Cordova Android apps process push notifications while closed?
In Google Cloud Messaging (which is the push notifications mechanism used by the PushPlugin) each application decides how to handle the notification. When a push notification arrives to the device, GCM triggers a BroadcastReceiver in the recipient application, and the application is responsible for handling the notification data.
Android apps can process push notifications when closed unless they are explicitly stopped by the user (in which case no notifications will reach the app until it is restarted again by the user). If they leave the foreground by the user switching to another app or going to the home screen, the can still receive and process notifications.
Yes. According to the PushPlugin you posted a link to, it seems that they can. When the app is not in the foreground, the notification is handled differently - a notification is added to the notification bar, and when it is tapped, it should open the app.
With PushPlugin, when sending push notifications to GCM (for GCM to send them to the device) one has to include a msgcnt key value pair after the message key value pair in the payload value in the JSON message, like this:
{
"GCM":"{\"data\":{\"message\":\"hello\",\"msgcnt\":\"1\"}}"
}
or else PushPlugin will not handle the notification when the app is in the background. It has to do with the way the GCMIntentService.java file is written in the plugin.
In my Android App I have used UrbanAirship to receive Push Notification. My web application sends me the notifications, which works great.
Now if my Push is disabled in my Android apps Push Preference, I am not getting any push messages - which works as expected. Now I made my Push Enable, Quick Question - when will my app receives those notification sent by my web app when my App was in disable mode.
Thanks,
Panache