Flutter-添加notification Service Extension(用于推送通知中的图像)后出现[fire



使用firebase phone_auth可以正常工作,直到我根据FlutterFire文档添加了通知服务扩展(通过Xcode(->https://firebase.flutter.dev/docs/messaging/apple-integration

未调用验证过程,错误显示

[firebase_auth/nootification not forwarded]如果禁用了应用程序委派swizzling,则uiapplicationdelegate接收到的远程通知需要转发到firauth的canhandlenootificationon:方法。

此错误仅发生在iOS上。我认为swizzling方法和扩展可能有一些冲突。

在经历了这个线程之后,我发现了以下解决方案:

在您的Podfile中,使用以下内容:

target 'ImageNotification' do
use_frameworks!
pod 'Firebase/Messaging'
end

在AppDelegate中,添加import Firebase并使用:

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

// This is the important new part:
override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
super.application(application, didReceiveRemoteNotification: userInfo, fetchCompletionHandler: completionHandler)
let firebaseAuth = Auth.auth()
Messaging.messaging().appDidReceiveMessage(userInfo)
if (firebaseAuth.canHandleNotification(userInfo)){
completionHandler(.noData)
return
}
}
}

最新更新