【问题标题】:React-Native Firebase: How to show ALWAYS the notification banner?React-Native Firebase:如何始终显示通知横幅?
【发布时间】: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


    【解决方案1】:

    这个问题似乎是 Android 10 的问题。该通知在 Android 9.0 上运行良好。一旦我了解有关 Android 10 修复的更多信息,我将立即更新此答案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-11
      • 1970-01-01
      • 1970-01-01
      • 2013-10-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多