【发布时间】:2019-10-04 05:59:51
【问题描述】:
我正在使用 react-native-firebase 为 react-native 应用程序设置通知。 iOS 工作,在 Android 中我有奇怪的行为,通知横幅仅在栏中已有另一个通知时显示。
问题演示: 发送同一条消息两次,第一条消息只显示在上栏,第二条消息带有横幅。
目标: 我希望通知始终与横幅一起显示。
我在 android 上收听消息并生成本地通知。我希望通过设置 show_in_foreground: true 来始终显示通知。但这只是部分情况。上面 gif 中的行为对于处于前台或后台的应用程序是相同的。
this.messagingListener = firebase.messaging().onMessage((message) => {
const { data} = message;
const localNotification = new firebase.notifications.Notification({
show_in_foreground: true,
sound: 'default'
})
.android.setChannelId('fcm_default_channel')
.setTitle(data.title)
.setBody(data.body)
.android.setColor('#222222') // you can set a color here
.android.setPriority(firebase.notifications.Android.Priority.High);
firebase.notifications()
.displayNotification(localNotification)
.catch(err => console.error(err));
});
【问题讨论】:
标签: android reactjs firebase react-native firebase-cloud-messaging