嗨我正在使用react native firebase通知我成功整合它和通知即将到来的平台,但适用于 android heads up are not coming 当应用程序在前景或后台时 . 我阅读了有关这方面的所有问题,但没有任何线索 .
应用环境:
-
"react":"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 device ,因为它只在app托盘中显示通知然后我检查了 settings > my_app > notifications > show floating notification
turned on
然后抬头开始进入该设备但后来我尝试了 one plus device ,因为它没有显示 .
我检查了所有这些问题
-
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
在奥利奥,我认为它没有表现出来 . 因为mi有android N.请帮忙!谢谢 .