0

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 ??

Aung Myat Hein
  • 4,018
  • 1
  • 36
  • 42
EmBeCoRau
  • 327
  • 1
  • 4
  • 14

1 Answers1

0

I think your issue relative permission on device, did you request grant permission on device ? If user has granted permission, you should check app on android and ios device because sometime ios 9 does not support display a notification while the app is running in foreground.

Luis Dinh
  • 1
  • 1