简体   繁体   English

当应用程序在 iOS 前台时如何处理 Flutter FCM 推送通知?

[英]How to handle Flutter FCM push notification when app in foreground for iOS?

I'm using local notification when app in foreground, on iOS still cannot get notification when app in foreground but on Android it works perfectly.我在应用程序在前台时使用本地通知,在 iOS 上当应用程序在前台时仍然无法收到通知,但在 Android 上它运行良好。

The problem is how to handle push notification when app in foreground for iOS ?问题是如何在 iOS 前台应用程序时处理推送通知?

This my AppDelegate.swift :这是我的 AppDelegate.swift :

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {override func application(
      _ application: UIApplication,
      didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {

      if #available(iOS 10.0, *) {
        // For iOS 10 display notification (sent via APNS)
        UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate

        let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
        UNUserNotificationCenter.current().requestAuthorization(
          options: authOptions,
          completionHandler: {_, _ in })
      } else {
        let settings: UIUserNotificationSettings =
        UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
        application.registerUserNotificationSettings(settings)
      }

      application.registerForRemoteNotifications()

      FirebaseApp.configure()
      GeneratedPluginRegistrant.register(with: self)
      return super.application(application, didFinishLaunchingWithOptions: launchOptions)


    }
}

I assume you're using the flutter_local_notifications plugin for local notifications and firebase_messaging for push notifications.我假设你正在使用的flutter_local_notifications插件本地通知和firebase_messaging推送通知。 As of right now, these two plugins do not work together.截至目前,这两个插件不能一起工作。 This is documented in the readme of the first plugin, and the issue is being tracked on both plugins.这记录在第一个插件的自述文件中,并且正在两个插件上跟踪该问题。 You'll just have to wait for the pull request on firebase_messaging to be merged.您只需要等待firebase_messaging上的拉取请求被合并。

See this issue for more details.有关更多详细信息,请参阅此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter iOS 应用程序在前台时的 FCM 推送通知 - Flutter FCM push notification for iOS when app is in foreground iOS如何在应用程序处于前台时处理解析JSON推送通知 - iOS How to Handle Parse JSON Push Notification when App is in Foreground 应用程序处于前台时未收到推送通知 ios flutter - Push Notification not received when app is in foreground ios flutter 当应用程序处于前台时(颤动)在 iOS 中接收 fcm - Receiving fcm in iOS when app is foreground (flutter) iOS在前台运行时如何更改推送通知标题? - iOS how to change push notification title when app is running in foreground? 如何在iOS应用程序的前台同时出现多个推送通知时进行处理 - how to handle while multiple push notification comes at same time in foreground of app in iOS 前台应用程序抖动时未收到 Firebase 推送通知? - Firebase Push Notification not received when flutter app in foreground? iOS 10.0 *处理前台推送通知 - iOS 10.0 * Handle Push notification in foreground unity IOS firebase 处理前台推送通知 - Unity IOS firebase handle foreground push notification 当应用程序在后台时处理 iOS 推送通知 - Handle iOS Push Notification when app in backgroud
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM