gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 10:26:41 27 4
gpt4 key购买 nike

当应用程序位于前台时,我使用本地通知,在 iOS 上,当应用程序位于前台时,仍然无法收到通知,但在 Android 上,它工作得很好。

问题是当 iOS 应用程序处于前台时如何处理推送通知?

这是我的 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)


}
}

最佳答案

我假设您使用 flutter_local_notifications 插件来发送本地通知,使用 firebase_messaging 来发送推送通知。截至目前,这两个插件不能一起工作。这记录在第一个插件的自述文件中,并且正在两个插件上跟踪该问题。您只需等待 firebase_messaging 上的拉取请求即可合并。

参见this issue了解更多详情。

关于ios - iOS 应用程序在前台时如何处理 Flutter FCM 推送通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60003099/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com