hi i am using react native firebase for notifications i succeed integrating it and notifications are coming for both platform but for android heads up are not coming when app is in either foreground or background. I read all of the issues regarding this but did't got any clue.
app environment:
- "react": "16.3.1",
- "react-native": "0.55.3",
- "react-native-firebase": "4.2.0",
- firebase cloud messaging tab in console for sending message -- tried with advanced options too
so when app is in foreground app need to handle notification that's how i am doing:
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
}
}
start i was using mi device in that it was showing notification in only app tray then i checked in settings > my_app > notifications > show floating notification
turned on
then heads up started coming in that device but then i tried with one plus device in that it's not showing.
i checked all of this issues
- 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
In oreo its not showing i think. because mi is having android N. Please help !!! Advance thanks.