Solvedflutterfire [firebase_auth] Method swizzling problem with phone auth iOS

I'm having an issue with firebase_auth verifyPhoneNumber on iOS.
I followed all requirements on documentation. APN works fine (FCM can be received). But whenever verifyPhoneNumber called, it always fail with exception message:

If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotification: method

I did pod upgrade to firebase_auth 6.3.0 and flutter to 1.7.11-pre43
still got the same problem. Android build works fine.

33 Answers

βœ”οΈAccepted Answer

@cielo
Hi, Yes i did. I got Token mismatch too. But, when i fixed AppDelegate.swift, i solved this error.

Here is my AppDelegate.swift Code

import UIKit
import Flutter
import Firebase
import FirebaseAuth
import UserNotifications
import FirebaseInstanceID

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
  ) -> Bool {
        FirebaseApp.configure()
        GeneratedPluginRegistrant.register(with: self)
        return true
  }
    override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        let firebaseAuth = Auth.auth()
        firebaseAuth.setAPNSToken(deviceToken, type: AuthAPNSTokenType.unknown)

    }
    override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        let firebaseAuth = Auth.auth()
        if (firebaseAuth.canHandleNotification(userInfo)){
            print(userInfo)
            return
        }
    }
}

Other Answers:

Firebase Auth + APN works on development mode but I get token mismatch when building release

More Issues: