i am trying to received data messages on my app react-native using firebase.messaging().onMessage, i am sending messages through firebase console, but the messages is not calling onMessage method.
i am trying like this
constructor(props){
super(props);
this.onMessageListener();
}
onMessageListener = firebase.messaging().onMessage(message => console.log("mensagem enviada"))
"react-native": "0.55.4",
"react-native-firebase": "^4.3.8",
Have same issue
I'll assume you are using the fcm token to target the message to a single device.
What versions of firebase-core and firebase-messaging are you using?
I also have the same issue, I noticed It worked when I had the app on background even though In the documentation the following code is proposed for foreground.
componentWillUnmount() {
this.messageListener();
}
To me it seems weird that this method just gets called on the ComponentWillUnMount for the component... maybe this behavior is expected?
@aaalive, i solved this issue.
So, my problem was that i was sending messages through firebase console, but the messages sent from there are notifications, calling the method:
firebase.notifications().onNotification((notification: Notification) => {
// Process your notification as required
});
For sending messages, read this documentation. Using the FCM admin, you can send messages to devices using fcm token.
@kimberlyluna , i am using this versions:
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.1.0"
Thank you for your answer. None of the call back of this lib called
unfortunately. I'm trying to understand at the moment may be this
watchman.. or so
On Mon, Sep 10, 2018, 7:29 PM Victor Marcel Gomes notifications@github.com
wrote:
@aaalive https://github.com/aaalive, i could fix this issue.
So, my problem was that i was sending messages through firebase console,
but the messages sent from there are notifications, calling the method:firebase.notifications().onNotification((notification: Notification) => {
// Process your notification as required
});For sending messages, read this documentation
https://firebase.google.com/docs/cloud-messaging/admin/send-messages.
Using the FCM admin, you can send messages to devices using fcm token.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/invertase/react-native-firebase/issues/1473#issuecomment-419975782,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AWF0p3nng1hjMdZu--1vwhmOrlQNrJOFks5uZpNpgaJpZM4Wf4jV
.
Solved issue by using react-native-firebase notifications module, instead of messaging
I've not tried your solution but if the FCM console messages are only caught by onNotification listener, then why firebase official example for JS catches FCM console messages with onMessage ?
Most helpful comment
@aaalive, i solved this issue.
So, my problem was that i was sending messages through firebase console, but the messages sent from there are notifications, calling the method:
For sending messages, read this documentation. Using the FCM admin, you can send messages to devices using fcm token.