I\'ve used react-native-fcm for remote notification in android and iPhone.
react-native-fcm
In Android foreground I\'m not be able to getting re
As per the library issues listed here you can try two things:
just pass show_in_foreground in your data property in remote notification
android shows notification only when app state is killed or background. To display notifications in app foreground, you need to show local notification.
Sample code:
FCM.on(FCMEvent.Notification, notif => {
if (!notif.opened_from_tray) {
showLocalNotification();
}
});
showLocalNotification() {
FCM.presentLocalNotification({
id: new Date().valueOf().toString(), // (optional for instant notification)
title: "Test Notification with action", // as FCM payload
body: "Force touch to reply", // as FCM payload (required)
show_in_foreground: true // notification when app is in foreground (local & remote)
});
}
Full code is here