ios - 当应用程序在 iOS 的前台时如何处理 Flutter FCM 推送通知?
问题描述
我在前台应用程序时使用本地通知,在 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
合并的拉取请求即可。
有关详细信息,请参阅此问题。
推荐阅读
- matlab - “面积”和“周长”维度 - Matlab
- javascript - Angular 9 Google Maps API Place Autocomplete
- c# - 检查字符串是否包含 Visual Basic 列表中的任何字符串
- python - 使用循环时无法在 django 中加载静态图像
- python - 树莓派相机的python线程
- git - Jenkins Multibranch Pipeline with Github source - 按目标分支发现拉取请求
- c++ - 一个接一个的调用方法被称为 c++
- javascript - JavaScript Promise 如何在幕后工作
- javascript - 刚才评估了如何打印下面的数组值
- class - Kotlin:访问枚举值会生成空指针异常