当从后台移除应用时,Android FCM不会收到通知 [英] Android FCM not receiving notifications when app is removed from background

查看:2696
本文介绍了当从后台移除应用时,Android FCM不会收到通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

手机是OnePlus3T。氧OS的建立是4.1.6。应用程序在后台但在内存中处于前台时收到通知。但是当应用程序不在内存中时不会收到通知,即从内存中移出。
在安卓操作系统版本4.2,5.1.1,6.0.1,7.1.1 Lineage操作系统的其他设备上收到通知,甚至应用程序不在内存中。



请提出一些建议。
在此先感谢。

解决方案




$ b


1-使用通知负载



$ b

可以使用 data 标签或 notification 标签发送通知有效负载。 / p>

使用数据标记

 <$ 
title:welcome,
description:to your app,
image:image_url,
deeplink:deeplink,
- -
}

触发FirebaseMessagingService onMessageReceived 方法。
它在某些设备上不起作用,当应用程序在后台时。

使用通知

 notification{
title:title,
description:description ,
click_action:活动被打开
..
}

这是处理android系统的尝试并显示通知,这种情况下,您的FirebaseMessagingService的方法将不会调用通知,这种情况下 onMessageReceived 即使应用程序处于背景。
这是一个缺点 - 你不能自定义通知,因为它是由Android系统处理的。
更多信息


2-在设备设置中启用自动启动

当您使用 data 和app被杀死通知将不会显示。
如果您观察到您将看到的日志猫

  W / GCM-DMM:广播意图回调:result = CANCELED forIntent {act = com.google.android.c2dm.intent.RECEIVE pkg = com.cabipool(has extras)} 

可以在oneplus 3设置中解决
- >应用程序 - >点击齿轮 - >上次打开应用程序选择应用程序自动启动 - >找到您的应用程序启用开关$ / $>

这个问题在像Vivo,Oppo,xiaomi,华硕等大多数设备上加了一个3加

步骤来启用应用程序自动启动非常基于设备制造商。


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- 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 open 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.

这篇关于当从后台移除应用时,Android FCM不会收到通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆