Reputation: 36
I have an app that shows notifications perfectly in the foreground and background but not working when the app is in front/open.
messaging().onNotificationOpenedApp(remoteMessage => {
console.log(
'Notification caused app to open from background state: 1111111-22333 app open in background' ,
remoteMessage.notification,
);
and
messaging().onMessage(async (remoteMessage) => {
console.log('Push Notification: laveshmahajana1 ',remoteMessage)
PushNotificationIos.addNotificationRequest({
id: remoteMessage.messageId,
body: remoteMessage.notification.body,
title: remoteMessage.notification.title,
userInfo: remoteMessage.data,
});
```
Upvotes: 1
Views: 1209
Reputation: 7193
Have a try by using https://github.com/zo0r/react-native-push-notification npm.
For Example:
import PushNotification from "react-native-push-notification";
messaging().onMessage(async (remoteMessage) => {
PushNotification.localNotification({
title: remoteMessage.data.title,
message: remoteMessage.data.body,
})
})
Upvotes: 2