【发布时间】:2018-11-25 06:27:40
【问题描述】:
您好,我正在使用react native firebase 进行通知,我成功集成了它,并且两个平台的通知都将到来,但是当应用程序处于前台或后台时,android head up are not come。我阅读了有关此的所有问题,但没有任何线索。
应用环境:
- “反应”:“16.3.1”,
- "react-native": "0.55.3",
- “react-native-firebase”:“4.2.0”,
- firebase cloud messaging tab in console 用于发送消息 - 也尝试使用高级选项
所以当应用程序在前台时,应用程序需要处理通知,这就是我正在做的事情:
componentDidMount() {
this.checkFirebase();
}
registerFbCloudMessagingListener = () => {
firebase.notifications().onNotification(notification => {
if (Platform.OS === "android") {
notification.android.setChannelId("forgroundnotification");
}
firebase.notifications().displayNotification(notification);
});
};
async checkFirebase() {
const enabled = await firebase.messaging().hasPermission();
if (enabled) {
// user has permissions
this.registerFbCloudMessagingListener();
} else {
// user doesn't have permission
this.requestFbPermission();
}
}
async requestFbPermission() {
try {
let permission = await firebase.messaging().requestPermission();
if (permission) {
this.checkFirebase();
}
// User has authorised
} catch (error) {
// User has rejected permissions
}
}
开始我正在使用 mi 设备,因为它仅在应用程序托盘中显示通知,然后我签入 settings > my_app > notifications > show floating notification turned on 然后抬头开始进入该设备,但后来我尝试使用 一加设备,因为它没有显示。
我检查了所有这些问题
- https://github.com/invertase/react-native-firebase/issues/500
- https://github.com/invertase/react-native-firebase/issues/357
- https://github.com/invertase/react-native-firebase/issues/595
在 oreo 我认为它没有显示出来。因为 mi 有 android N。 请帮忙 !!!提前谢谢。
【问题讨论】:
-
你解决了这个问题吗?我也一样
-
抱歉回复晚了,我会尽快分享我是怎么做到的。但这可能需要一些时间,因为我很忙。 @普拉文
-
嘿!我遇到了类似的问题,很想看看它是如何解决的。
-
抱歉延迟回复我已经添加了答案,请检查是否有帮助。
标签: android firebase react-native firebase-cloud-messaging react-native-firebase