I have background notifications showing fine, but I also want to show notifications when I receive them on foreground for some very important tasks.
I have read the documentation, I don't see anywhere with local notifications examples.
Previous versions used to have a method like this one
const notification = new firebase.notifications.Notification()
firebase.notifications().displayNotification(notification);
How do I display notifications within the app with the current version?
You need to use a local notifications library. We're building Notifee, however there are free alternatives available too.
FCM is only responsible for displaying remotes.
I use a combination from wix-navigation and this library for display notification.
Something like this
import messaging from '@react-native-firebase/messaging';
import { Notifications } from 'react-native-notifications';
messaging().onMessage(async (remoteMessage) => {
console.log('A new FCM message arrived!', JSON.stringify(remoteMessage));
Notifications.postLocalNotification(
remoteMessage.notification,
parseInt(remoteMessage.messageId.match(/\d+/g).join(''), 10),
);
});
In the componentMount of my notificationHandler
Is there any update
@himanshi7046 do you see any updates here? If not, there are no updates. This is an issue closed from April 30, why would there be updates? That's not how things work in open source - it's all in the open so what you see is what you get. Opening new issues with full details is the way to get new information vs posting on closed issues