奥利奥没有在后台调用 FCM 通知 [英] FCM Notifications not getting called in background for Oreo

查看:28
本文介绍了奥利奥没有在后台调用 FCM 通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户未连接到 xmpp 时,我正在使用 FCM 通知进行聊天.

I am using FCM notifications for chat when user is not connected to xmpp.

FCM 中有两种通知模式1.通知消息2. 数据消息

There are 2 modes of Notifications in FCM 1. Notifications Message 2. Data Messages

如果我的应用从最近删除中清除,我将使用数据消息作为通知消息不会出现

I an using Data messages as Notification messages won't come if my app is cleared from recents

这种方法适用于除奥利奥以外的所有版本.

This approach is working fine for all the version except Oreo.

对于 Oreo,我仅在应用未连接到 xmpp 且未连接到前台时才会收到通知.我的 onMessageReceived 方法被调用了.

For Oreo, I only get notifications if the app is not connected to xmpp and in foreground. My onMessageReceived method is getting called.

但是当应用被杀死或从最近的应用中删除时,同样的情况不会发生.

But the same is not happening when the app is killed or removed from recents ONLY for Oreo.

我在一加 3 设备上试过.

I tried on One Plus 3 device.

感谢任何帮助.

推荐答案

这可能为时已晚,但 One Plus 手机有一项称为电池优化的功能.关闭应用的电池优化后,您将开始接收后台通知.我的一加 5T 也有同样的问题.

This might be too late for an answer but One Plus phones have a feature called battery optimisation. You will start receiving the background notifications as soon as you turn the battery optimisation off for your app. I had the same problem with my One Plus 5T.

这篇关于奥利奥没有在后台调用 FCM 通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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