firebase-ios-sdk
firebase-ios-sdk copied to clipboard
Phone Auth not working in iOS 16 simulator.
Description
For our app, in order to login, we use Phone Authentication. When testing on any OS below iOS16 in the iOS Simulator, it works perfectly for both test numbers and live phone numbers.
But now with iOS16, it throws the following error:
"Error Domain=FIRAuthErrorDomain Code=17048 "Token mismatch" UserInfo={NSLocalizedDescription=Token mismatch, FIRAuthErrorUserInfoNameKey=INVALID_APP_CREDENTIAL}"
I've tried it in both Sandbox, Production & Unknown APNs environments, but nothing fixes it.
Reproducing the issue
Submit a number to Phone Authentication
finalPhone = "+" + "12345678910"
PhoneAuthProvider.provider(auth: Auth.auth()).verifyPhoneNumber(finalPhone, uiDelegate: nil) {
verificationID, error in
if let error = error {
print(error)
completion(false)
return
} else {
UserDefaults.standard.set(verificationID, forKey: "authVerificationID")
completion(true)
}
}
Firebase SDK Version
master
Xcode Version
14.0
Installation Method
Swift Package Manager
Firebase Product(s)
Authentication
Targeted Platforms
iOS
Relevant Log Output
No response
If using Swift Package Manager, the project's Package.resolved
Expand Package.resolved
snippet
Replace this line with the contents of your Package.resolved.
If using CocoaPods, the project's Podfile.lock
Expand Podfile.lock
snippet
Replace this line with the contents of your Podfile.lock!
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
@Archetapp are you able to use phone auth successfully via our sample app?
Hey @Archetapp. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Having the same issue (using via react-native-firebase).
As @Archetapp described, it works fine with previous iOS versions - doesn't work since developer beta iOS 16, now tested on stable release with same results
It works on devices, but I think it might be because it uses verification via notification, whereas simulator defaults to recaptcha. Seems to me it might be that recaptcha isn't able to open on new version of Safari or something like that.
We could test that by enforcing recaptcha on device as well as see if it fails, but I am not sure how I could do that.
Error from react-native-firebase, comment says // this fails for some browsers. :(
cc @morganchen12
Looks like this is caused by APNS support in the simulators in iOS 16+. The Auth SDK is trying to use APNS instead of captcha since it's available, but #9968 needs to be resolved before this can work successfully. (Thanks to Rosalyn for investigating.)
Would you prefer if we forced captcha on simulators or just used APNS?
So, in my case, we're not getting any response back at all. It just keeps on spinning. We've tried on iOS 15 & 16 simulators.
.package(url: "https://github.com/firebase/firebase-ios-sdk",
from: "9.2.0"),
So, in my case, we're not getting any response back at all. It just keeps on spinning. We've tried on iOS 15 & 16 simulators.
.package(url: "https://github.com/firebase/firebase-ios-sdk", from: "9.2.0"),
Ok, we actually got it to work by going into Info.plist
and adding FirebaseAppDelegateProxyEnabled
with a value of NO
. This disables swizzling, which Firebase actually relies on for some features -- so be warned. Look into it first. If your features aren't part of those that need swizzling, then try this out.
Thanks for answering @morganchen12. I am fine with using notifications on sim, once it's supported. But shouldn't it revert to recaptcha when it fails like this? Also for testing it would be actually nice if we could switch between the two methods manually and test both scenarios separately.
I'm having the same issue here with iOS 16 and Ventura. It works fine on a real device but i'd much prefer spinning up a bunch of emulators for testing and debugging. Hoping to have an answer soon
It was happening to my colleague while he was using Ventura beta. Then stable version of Ventura has been released. I upgraded to it. Now it happens to me as well. There aren't any issues on real devices but on simulators it gives token mismatch error.
By reading the previous comments, looks like it may have to do with updating to Ventura. I just updated a few hours ago and as soon as I updated the phone auth stopped working. Works on my device, but not in simulator.
I was running the simulator before updating to Ventura and it was working fine.
UPDATE: it is worth mentioning that it was running just fine in iOS 16 before updating to Ventura.
Any suggestions?
Facing same issue at work after updating to Ventura Public Stable and Xcode 14.
Facing same issue at work after updating to Ventura Public Stable and Xcode 14.
Same. In my case, Firebase phone auth was working fine on iOS simulator from production project on macOS Monterey.
Updated to macOS Ventura 3 days back and now getting Token Mismatch
error while trying Firebase Phone Auth on iOS simulator.
Thanks everyone for reporting. I'm making a workaround to force to recaptcha flow in the ios 16 simulators. Please try out the changes (https://github.com/firebase/firebase-ios-sdk/pull/10426) if you can and let me know if it fixes the issue for you. Thanks!
Thanks everyone for reporting. I'm making a workaround to force to recaptcha flow in the ios 16 simulators. Please try out the changes (#10426) if you can and let me know if it fixes the issue for you. Thanks!
@renkelvin I want to test, looks like the merge has not happened? Or where or how can I try the changes?
Thank you
Thanks everyone for reporting. I'm making a workaround to force to recaptcha flow in the ios 16 simulators. Please try out the changes (#10426) if you can and let me know if it fixes the issue for you. Thanks!
@renkelvin I want to test, looks like the merge has not happened? Or where or how can I try the changes?
Thank you
Yeah, I'd like to get some confirmations before merging it.
You can pick up the changes by:
- Point your pod dependency to the dev branch with
pod 'FirebaseAuth', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'fix-apns-16'
. - Manually apply the changes to local installed pod files.
- Choose branch 'fix-apns-16' when add firebase-ios-sdk as package dependency.
Thanks!
@renkelvin,
Sorry I am not using pods, and when I tried to point out to the "fix-apns-16" branch, through SPM, I get an error.

Any ideas?
@renkelvin,
Sorry I am not using pods, and when I tried to point out to the "fix-apns-16" branch, through SPM, I get an error.
![]()
Any ideas?
Not sure. Do you use these Firebase products as well? Seems unrelated to the changes I'm making.
@renkelvin, Sorry I am not using pods, and when I tried to point out to the "fix-apns-16" branch, through SPM, I get an error.
Any ideas?
Not sure. Do you use these Firebase products as well? Seems unrelated to the changes I'm making.
I think I found the issue, I had those frameworks on my app target. I will try to test your changes in a few minutes and will get back to you.
@renkelvin , works like a charm.. any ideas as to when it will be released?
@renkelvin , works like a charm.. any ideas as to when it will be released?
Thanks for trying it out. The next release is Nov 15th. I will keep the fix-apns-16
branch in case anyone needs it before the release.
Any news about this issue? It suddenly appeared and Unfortunately I do not think that we can do anything about it unless Xcode gets updated.
Any way to push this release sooner?
@SaudElabdullah and @ashtoncofer, this bug only affects testing on iOS 16 simulator, you can point to the fix-apns-16
branch for testing, then revert it back when ready to release. That's what I am doing at least, then I will udpate on Nov 15 when they released it.
@renkelvin Will this go to 10.2.0 release?
@renkelvin Will this go to 10.2.0 release?
Yeah.
@renkelvin @rosalyntan Would that be just https://github.com/firebase/firebase-ios-sdk/pull/10426 PR? Can you update CHANGELOG for the release?
Yes.
CHANGELOG updated here https://github.com/firebase/firebase-ios-sdk/pull/10457
Same for me. Looking forward to 10.2.0
confirmed as working 🚀 thanks @renkelvin