奥利奥没有在后台调用 FCM 通知

FCM Notifications not getting called in background for Oreo(奥利奥没有在后台调用 FCM 通知)
本文介绍了奥利奥没有在后台调用 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 通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)