flutter 2 fcm ios apn issue



firebase FCM在扑动2.2.2中不适合我,我试图在我的ios应用程序中实现推送通知,并得到此错误:

8.3.0 - [Firebase/Messaging][I-FCM002022]在检索发件人ID '*************'的FCM令牌之前未设置APNS设备令牌。此FCM令牌的通知将不会通过APNS传递。是一旦设置了APNS设备令牌,一定要重新检索FCM令牌。

这个问题已经发生一个月了。

我遵循了本文和文章中的步骤

推送通知在Android上工作得很好,问题是在iOS上

这是我的appdelegate。swift

import UIKit
import Flutter
import Firebase
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Use Firebase library to configure APIs
FirebaseApp.configure()
if #available(iOS 10.0, *) {
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self
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()
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}

你必须添加

Messaging.messaging().apnsToken = deviceToken

之前
return super.application(application, didFinishLaunchingWithOptions: launchOptions)

最新更新