【发布时间】:2018-07-18 15:01:15
【问题描述】:
我有一个使用 react native 和 firebase 进行推送通知的应用程序。 这是我发送给客户的通知:
'data' : {
'title' : ' ' + this.currentUser.email + ' send you a message !',
'text' : text,
'senderName' : this.currentUser.email,
'senderUid': this.currentUser.uid
}
我使用纯数据消息,并在我的代码中实现了一个接收通知的侦听器:
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)
})
我在模拟器中测试过,一切正常。当我在真实设备上运行它时,它可以调用onMessage 但firebase.notifications().displayNotification(showNotif) 不能按预期工作。它无法在屏幕上显示通知。
有人知道这个问题吗??
【问题讨论】:
标签: react-native push-notification firebase-cloud-messaging react-native-firebase