手机是一加3T.氧气操作系统版本为 4.1.6.当应用程序在后台但在内存中时,应用程序会收到通知.但是当应用程序不在内存中时不会收到通知,即从内存中刷出.即使应用程序不在内存中,也会在具有 android OS 版本 4.2、5.1.1、6.0.1、7.1.1 Lineage OS 的其他设备上收到通知.
The phone is OnePlus3T. The oxygen OS build is 4.1.6. App receives notification when the app is in foreground on in background but in the memory. But does not receive notification when the app is not in memory i.e. swiped out of the memory. The notification is received on other devices having android OS verions 4.2, 5.1.1, 6.0.1, 7.1.1 Lineage OS even the app is not in the memory.
请提出一些建议.提前致谢.
Kindly suggest something. Thanks in advance.
我也遇到了同样的问题.
I also faced the same issue.
解决这个问题的两种方法
Two ways to solve this issue
1- 使用通知负载
通知负载可以使用data
标签或notification
标签发送.
notification payload can be send using data
tag or notification
tag.
使用数据
标签
"data" {
"title": "welcome",
"description" :"to your app" ,
"image" :"image_url",
"deeplink" :"deeplink",
- -
}
它将触发 FirebaseMessagingService onMessageReceived
方法.当应用程序在后台时,它在某些设备上不起作用.
it will trigger the FirebaseMessagingService onMessageReceived
method.
it will not work on some devices, when an app is in the background.
使用通知
"notification" {
"title":"title",
"description" : "description",
"click_action" :"activity to be open"
..
}
这是处理android系统尝试并显示通知,这种情况下你的FirebaseMessagingService的onMessageReceived
方法将不会调用.即使应用程序在后台,也会显示通知.这样做的一个缺点是 - 您不能自定义通知,因为它是由 Android 系统处理的.更多信息
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- 在设备设置中启用自动启动
2- Enable Auto start in device setting
当您使用 data
发送通知并且应用程序被终止时,将不会显示通知.如果你观察日志猫,你会看到
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) }
可以解决在一加3设置-->应用-->点击齿轮-->最后一个选项应用选择应用自动启动-->找到你的应用启用开关
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
这是 Vivo、Oppo、小米、华硕、一加 3 等大多数设备的问题.
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.
更新:
一加3和Android 8.0去掉了自动启动选项,现在你可以进入设置>电池>电池优化>(左上角三点菜单)高级优化>关闭高级优化.
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.
这篇关于从后台删除应用程序时,Android FCM 未收到通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!