I get a token mismatch error on iOS, on any of the latest versions. it does work with this old that someone made: https://stackoverflow.com/questions/57395948/flutter-firebase-phone-auth-always-returns-token-mismatch-on-ios
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.
Yes, I too getting this issue.
simply upgraded the firebase_auth version to latest and worked like charm.
firebase_auth: ^0.15.3+1
upgraded the firebase_auth version to latest, ^0.15.3+1, still same issue, tested on multiple different iphones
Yep, same here. Updating doesn't seem to do the trick. Really frustrated with this.
Is there any update on this? I've tried using both the APNs authentication key and APNs certificate as well and cannot seem to figure out why I see token mismatch.
This is wired, I also getting the Token mismatch issue while ago. Some time works some time did not. But this time i get worked with
firebase_auth:
git:
url: https://github.com/collinjackson/plugins.git
ref: 441417c2fed0ff26bf84a49ab2c5ffd2aa5487de
path: packages/firebase_auth
Steps I did
a verbose mode would be nice to see what kind of steps and requests are happening behind the scenes
For me, it started working as soon as I deployed it to test flight, but it still does not work when I try to run it locally on my phone (As I still get token mismatch).
Hi everyone!
I'm getting the same error. I found out odd behavior.
At first, I installed my newest app version, but it didn't work.
Next, I installed my older app version, and it worked.
Finally, I installed newest one again, and it worked.
Is there anything we can tell from this?
With some magic problem just disappeared today. What is more interesting - it is working now with both @nroobah solution and with simply latest version: firebase_auth: 0.15.4
p.s. struggled 3 days before that
Only thing to add - last time I tried different variations. This time I came up with one variation (not sure if it matters, but still):
I have same problem with firebase_auth: 0.15.4 in real device iPhone.
Simulator is working with 0.15.4
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
//Auth
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
}
}
Don't forget to add import FirebaseAuth !
@rignaneseleo 's fix worked for me as well.
One thing: I was seeing this warning:
2020-04-16 15:27:01.981926-0400 Runner[23543:7794346] Warning: Application delegate received call to -application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called.
Commenting out print(userInfo) fixed that for me.
edit
This is a very concerning issue, but now I can't "break" it anymore. It means there is something cached somewhere and that's causing this issue. This was only happening to me with 1 of my 2 iphones, which was annoying.
I tried:
But I can't break it anymore. My suspicion is something related to setAPNSToken() gets stuck / cached with a wrong setting somewhere and putting in the 2 overrides above fixes it.
I have now removed the overrides and it's working in subsequent builds. Will keep an eye on it..
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!
Hey, any news on this issue?
@rignaneseleo 's fix is still working, but as @MichaelM97 's said, it would be good to get a fix too on the plugin side!
I have realized that deleting your app without signing out first causes this problem.
You'll also notice that you are automatically logged in after reinstalling your app.
So if you are experiencing this, sign out of your app and restart the authentication process.
If you have installed OneSignal plugin for Flutter then you only need to do this in addition
override func application(_ application: UIApplication, didReceiveRemoteNotification notification: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if Auth.auth().canHandleNotification(notification) {
completionHandler(.noData)
return
}
}
I've been following this issue since 0.16.1 and now with the release of 0.18.0 I'm getting the same problem, is no one looking for this problem? Man, I'm really stuck here, I already tried the @rignaneseleo fix in both versions and still doesn't woking. I already follow all the steps in https://firebase.flutter.dev/docs/auth/phone and the problem still persists, why apple makes things incredible complicated???? It's really frustanting, I've been trying to fix this for 2 weeks without any success. The thing is it's working on emulator but not working on real device, how can I understand this apple way to make things?? Can anyone give some update, please?
Hello @Ehesp @Salakar, on latest 0.18.0+1 there is
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[[FIRAuth auth] setAPNSToken:deviceToken type:FIRAuthAPNSTokenTypeProd];
}
so its registering as prod certificate, where I think it should be FIRAuthAPNSTokenTypeUnknown so apple can determine it automatically
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[[FIRAuth auth] setAPNSToken:deviceToken type:FIRAuthAPNSTokenTypeUnknown];
}
@diegogarciar good spot, are you able to change this locally and try it out? Happy to send up a fix release once confirmed
Yes I already did it locally and it worked instantly. Seems the way to go.
Thank you!
Closing pending merge & release of https://github.com/FirebaseExtended/flutterfire/pull/3345. Thanks @Ehesp
Any news on the release?
Most helpful comment
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 errorsToken mismatchand thenERROR_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
Don't forget to add
import FirebaseAuth!