【问题标题】:Firebase Push Notification not received when flutter app in foreground?在前台颤动应用程序时未收到 Firebase 推送通知?
【发布时间】:2020-02-24 10:31:19
【问题描述】:

我正在使用 firebase_messaging 进行 Firebase 推送通知。当应用程序在后台或应用程序被强制关闭但在前台应用程序时没有收到时,我收到了推送通知。

第二个问题是没有应用程序图标的推送通知显示。它显示空白方形图标。

【问题讨论】:

    标签: android ios flutter dart


    【解决方案1】:

    应用在前台时firebase不显示推送通知,所以我们需要为Firebase配置本地通知

    检查这个包

    Library for Local Notification

    【讨论】:

    • 你的意思是 onMessage() 函数,我在那里接收 firebase 推送通知,我正在触发本地通知
    • showInNotification(Map pushMessageMap) { if (pushMessageMap != null) { String messageInNotification = pushMessageMap["alert"]; if (messageInNotification != null) { String notificationPayload = getPushMapToString(pushMessageMap); flutterLocalNotificationsPlugin.show(0, 'NAME', messageInNotification, platformChannelSpecifics, payload: notificationPayload, ); } } }
    • 是的,我在 onMessage() 中使用了这个函数
    • 当我点击推送或本地通知时,你能告诉我如何通过主屏幕推送特定屏幕
    • 我想在点击推送通知时打开我的应用程序的特定屏幕,然后点击后退按钮显示我的应用程序的主屏幕
    【解决方案2】:

    您可以使用flutter_local_notification 推送通知,您必须使用以下代码,

    await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
        alert: true,
        badge: true,
        sound: true
      );
    

    在main方法中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-23
      • 1970-01-01
      • 1970-01-01
      • 2019-07-24
      • 1970-01-01
      • 1970-01-01
      • 2019-04-04
      • 1970-01-01
      相关资源
      最近更新 更多