【发布时间】:2018-07-15 04:17:24
【问题描述】:
我有一个使用 Firebase 推送通知的应用。 在我的应用中,我实现了 2 种方法:
firebase.messaging().onMessage((message) => {
senName = message.data.senderName;
senUid = message.data.senderUid;
const notification = new
firebase.notifications.Notification()
.setNotificationId('notificationId')
.setTitle(message.data.title)
.setBody(message.data.body)
.android.setChannelId('channel_id_foreground')
.android.setSmallIcon('ic_launcher');
firebase.notifications().displayNotification(notification)
});
和
firebase.notifications().onNotificationOpened((notificationOpen) => {
// Get the action triggered by the notification being opened
const action = notificationOpen.action;
// Get information about the notification that was opened
const notification = notificationOpen.notification;
});
如果我的应用程序在前台和后台运行,它将正确显示通知。如果我什么都不做,只是关闭应用程序,它就不会显示通知。
但是当我在前台点击通知时,它将运行到 onNotificationOpened 方法,然后我通过滑动关闭应用程序,它仍然正常显示通知。
因此,如果我之前录制过通知,它只会在关闭/滑动应用程序的情况下显示通知。
谁能帮帮我?
【问题讨论】:
-
您是否尝试过提高通知优先级?
标签: firebase react-native push-notification