I have an app that using react native and firebase for push notification. This is my notification that send to client:
'data' : {
'title' : ' ' + this.currentUser.email + ' send you a message !',
'text' : text,
'senderName' : this.currentUser.email,
'senderUid': this.currentUser.uid
}
I use data-only message, and in my code I implement a listener that received the notification:
this.onMessageListener = firebase.messaging().onMessage((message) => {
senName = message.data.senderName;
senUid = message.data.senderUid;
const showNotif = new firebase.notifications.Notification()
.setNotificationId('notificationId')
.setTitle(message.data.title)
.setBody(message.data.text)
.android.setChannelId('channel_id_foreground')
.android.setSmallIcon('ic_launcher');
firebase.notifications().displayNotification(showNotif)
})
I have tested in simulator, everything work fine. When I run it on real device, it can call onMessage
but firebase.notifications().displayNotification(showNotif)
doesn't work as expect. It can not show the notification to the screen.
Anybody know about this issue ??