【问题标题】:OneSignal does not showing notification when app is in foreground当应用程序处于前台时,OneSignal 不显示通知
【发布时间】:2021-12-13 16:26:16
【问题描述】:

我将我的颤振应用程序与 onesignal 集成,当应用程序在后台时它工作得很好,但在前台它正在接收通知但不知道为什么?

日志

flutter: OSNotificationReceivedEvent complete with notification: Instance of 'OSNotification'
VERBOSE: finishProcessingNotification: Fired!
VERBOSE: Notification display type: 7
VERBOSE: notificationReceived called! opened: NO
VERBOSE: finishProcessingNotification: call completionHandler with options: 7

前台处理程序

  OneSignal.shared.setNotificationWillShowInForegroundHandler(
      (OSNotificationReceivedEvent event) {
    event.complete(event.notification);
  });

【问题讨论】:

    标签: push-notification onesignal foreground foregroundnotification


    【解决方案1】:

    给你:

    OneSignal.shared
            .setNotificationWillShowInForegroundHandler((OSNotificationReceivedEvent event) {
               print('FOREGROUND HANDLER CALLED WITH: ${event}');
               /// Display Notification, send null to not display
               event.complete(null);
              
               this.setState(() {
               _debugLabelString =
                  "Notification received in foreground notification: \n${event.notification.jsonRepresentation().replaceAll("\\n", "\n")}";
          });
        });  
    

    您可以找到full example here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-10
      • 2018-01-12
      • 1970-01-01
      • 2017-06-25
      相关资源
      最近更新 更多