I'm building an app in react native, and I attached react-native-fcm
library to the code, in order to work with notification messages.
I have two main problems:
1) Notification from the firebase
doesn't look like the ordinary notification messages: it's not appear with app icon, it doesn't popup and presented when the screen is closed.
2) I wanted just to get the event of messaging, also here after reviewing the library code, I saw that notification get to the function: onMessageReceived
only if the app on foreground, like it say in the website.
But in the website I couldn't understand how to get the general event of catching notificaiton regardless to the appstate.
I also tried to implement class that extends FirebaseMessagingService
, and there the notification doesn't get to the onMessageReceived
override at all.
You will need to use FCM API and send data in data
field instead of using Firebase console or notification
field so that the method onMessageReceived
is always called regardless of whether the app is in foreground or background. When this method is called, you can create a notification as you like.
Read about FCM admin API at: https://firebase.google.com/docs/cloud-messaging/admin/
Read about FCM HTTP API at: https://firebase.google.com/docs/cloud-messaging/http-server-ref
You can use Postman to send notification if you choose to use FCM HTTP API.