[英]React-Native Firebase: How to show ALWAYS the notification banner?
I'm setting up notifications for a react-native app by using react-native-firebase.我正在使用 react-native-firebase 为 react-native 应用程序设置通知。 iOS works, in Android I have strange behaviour, that the notification banner only shows if there is already another notification sitting in the bar.
iOS 工作,在 Android 我有奇怪的行为,通知横幅只显示如果已经有另一个通知坐在酒吧。
Problem Demonstration: send the same message twice, the first message is only displayed in the upper bar, the second message is shown with a banner.问题演示:发送同一条消息两次,第一条消息只显示在上栏,第二条消息带有横幅。
Goal: I want the notifications to be always shown with a banner.目标:我希望通知始终与横幅一起显示。
I listen for messages on android and generate local notifications.我在 android 上收听消息并生成本地通知。 I was hoping to have the notification always showing by setting show_in_foreground: true.
我希望通过设置 show_in_foreground: true 来始终显示通知。 But that is only partially the case.
但这只是部分情况。 The behavior in the gif above is the same for the app being in the foreground or background.
上面 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));
});
This issue seems to be a Android 10 problem.这个问题似乎是 Android 10 问题。 The notification works fine on Android 9.0.
该通知在 Android 9.0 上运行良好。 I will update this answer as soon as i know more about a fix for Android 10.
一旦我了解有关 Android 10 修复程序的更多信息,我将立即更新此答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.