【问题标题】:Show firebase notifications when android app is open and with high priority当 android 应用程序打开并具有高优先级时显示 firebase 通知
【发布时间】:2020-04-17 11:01:02
【问题描述】:

我在应用程序中使用nativescript-plugin-firebase,当应用程序关闭时我会收到通知。

但是,如果应用程序打开,我不会收到任何通知。有什么方法可以在应用打开时强制显示推送通知,还是我必须在应用内创建带有声音的自定义通知?

我遇到的另一个问题是推送通知的显示方式。我使用Laravel-FCM 从服务器端发送推送通知,我将优先级设置为“高”,其他所有设置都设置为默认值,但是当我收到安卓设备的通知时,没有浮动通知,只有一个徽章图标以及通知中心的通知。

在应用通知设置中,有 Miscellaneous 通知类别,其中 Importance 设置为默认,振动设置为关闭,LED 灯也关闭,但如果我手动更改这些设置,然后 Firebase 通知会出现浮动通知和振动。

有什么方法可以让这些通知默认具有高优先级?

附:我正在测试的设备是小米红米 Note 8 Pro

【问题讨论】:

  • 你是用原生框架构建这个应用吗?
  • @haresh 我正在为应用程序使用 nativescript-vue。
  • Remdi 经常遇到问题,因为他们在手机上有自己的自定义 UI。您是否尝试检查运行未修改版本的 Android 的 Nexus / Pixels?另外让我们知道您在 Redmi 中使用的 Android 版本。
  • @Manoj 我没有在 nexus / 像素手机上尝试过。我可以在虚拟设备上进行测试,但我知道虚拟设备在 Firebase 通知方面存在棘手的问题,因此,我正在我拥有的这个物理设备上进行测试。设备上的 Android 版本是 9 PPR1.180610.011

标签: android firebase push-notification firebase-cloud-messaging nativescript


【解决方案1】:

在使用 Nativescript-firebase 时,我遇到了与您相同的问题。当应用打开时,推送通知被传递但不显示(见 onMessageReceived 回调)然后您可以使用 Nativescript-local-notification 显示应用打开时收到的推送通知的内容。

【讨论】:

  • 我就是这么想的。我想知道是否可以使用 Nativescript-local-notification 来显示所有 firebase 通知(包括在应用程序关闭时收到的通知)。这将解决我遇到的优先问题。
  • @Juky 你能分享代码 forceShowWhenInForeground 吗,优先级在 android 中不适合我
  • @iosDev 这里是代码: var firebase = require("nativescript-plugin-firebase"); firebase.init({ showNotifications: true, showNotificationsWhenInForeground: true....})
猜你喜欢
  • 2014-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-01
相关资源
最近更新 更多