I also faced the same issue.
Two ways to solve this issue
1- Using notification payload
notification payload can be send using data
tag or notification
tag.
using data
tag
"data" {
"title": "welcome",
"description" :"to your app" ,
"image" :"image_url",
"deeplink" :"deeplink",
- -
}
it will trigger the FirebaseMessagingService onMessageReceived
method.
it will not work on some devices, when an app is in the background.
using notification
"notification" {
"title":"title",
"description" : "description",
"click_action" :"activity to be open"
..
}
this is handled android system try and show the notification, this case onMessageReceived
method of your FirebaseMessagingService will not call.notification will be shown even app is in the background.
one disadvantage of this is - you can't the customize notification because it's handled by the Android system.
more info
2- Enable Auto start in device setting
when you send notification using data
and app is killed notification will not be shown.
if you observe the log cat you will see
W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.cabipool (has extras) }
can be solved
in oneplus 3 setting -->Apps --> click on gear wheel -->last option App select app auto launch --> find your app enable the switch
this the problem in most of the devices like Vivo,Oppo,xiaomi,Asus, one plus 3.
steps to enable app auto launch very based on device manufacturer.
Update:
OnePlus 3 and Android 8.0 the Auto-start option was removed, so now you can go to Settings> Battery> Battery Optimisation> (Three dots menu on the left-top corner) Advanced optimization> Turn off Advanced Optimization.