FCM通知未在Oreo的后台调用 [英] FCM Notifications not getting called in background for Oreo

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

问题描述

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

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

FCM中有2种通知模式 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

对于除Oreo以外的所有版本,此方法都适用.

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.

但是,仅对于Oreo,当该应用程序被杀或从最新消息中删除时,情况不会一样.

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

我在One Plus 3设备上尝试过.

I tried on One Plus 3 device.

感谢您的帮助.

推荐答案

这个答案可能为时已晚,但One Plus手机具有称为电池优化的功能.关闭应用程序的电池优化后,您将立即开始接收后台通知.我的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通知未在Oreo的后台调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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