Solvedflutterfire [firebase_auth] iOS verifyPhoneNumber Token mismatch

I get a token mismatch error on iOS, on any of the latest versions. it does work with this old that someone made:
But why it doesn't work on the original repository and after so many updates?

I tried using APNs Authentication Key.
I tried using the APNs Certificates instead.
I re-downloaded the google-services-json many times.
I think the fact that it works with the fix someone made means that there is something missing in package code or in the setup instructions.

23 Answers

βœ”οΈAccepted Answer

Same problem with firebase_auth: 0.15.5+3: on the simulator, I get the CAPTCHA code and it works, on a physical iPhone I get the errors Token mismatch and then ERROR_MISSING_VERIFICATION_ID, The phone auth credential was created with an empty verification ID.

Everything seems to have set up well on firebase (certificates, APNs, etc.): the normal notifications work well.

EDIT: I made it working adding these 2 override methods in the AppDelegate.swift

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)){

Don't forget to add import FirebaseAuth !

Other Answers:

This is still present on version 0.16.1, and @rignaneseleo's fix is still working, but it would be good to get a fix on the plugin side!

I have same problem with firebase_auth: 0.15.4 in real device iPhone.
Simulator is working with 0.15.4

More Issues: