The FCMService.java
handles all the background notification tasks perfectly if the app is running in foreground. When i close the application from the app drawer the aforementioned service stops handling the delivered fcm message, instead throws following log
W/GCM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.technobees.nalamdot (has extras) }
I've tested in following devices with user enabling isIgnoringBatteryOptimizations
using the permission ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
.
- Oneplus 3t
- Xiaomi Redmi 4, Note 4, Note 5 pro (MIUI optimization disabled)
Message sending from node server
var message = {
'data': notification,
'token': token,
"android": {
"ttl": 0,
"priority": "HIGH"
},
"webpush": {
"headers": {
"TTL": "3000"
}
}
};
in FCMService.java
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Map<String, String> data = remoteMessage.getData();
//passing the data to the NotificationUtils -> which takes action based on "event"
}