firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

Phone Auth not working in iOS 16 simulator.

Open Archetapp opened this issue 2 years ago • 3 comments

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!

Archetapp avatar Sep 14 '22 18:09 Archetapp

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Sep 14 '22 18:09 google-oss-bot

@Archetapp are you able to use phone auth successfully via our sample app?

morganchen12 avatar Sep 14 '22 22:09 morganchen12

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!

google-oss-bot avatar Sep 21 '22 01:09 google-oss-bot

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. :( image

cc @morganchen12

tomas-petrovcin avatar Sep 26 '22 08:09 tomas-petrovcin

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?

morganchen12 avatar Sep 27 '22 21:09 morganchen12

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"),

scottsmithdev avatar Sep 28 '22 19:09 scottsmithdev

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.

scottsmithdev avatar Sep 29 '22 15:09 scottsmithdev

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.

tomas-petrovcin avatar Oct 04 '22 10:10 tomas-petrovcin

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

kevb10 avatar Oct 28 '22 15:10 kevb10

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.

AlpSha avatar Oct 28 '22 16:10 AlpSha

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?

jhoanarango avatar Oct 29 '22 03:10 jhoanarango

Facing same issue at work after updating to Ventura Public Stable and Xcode 14.

zees98 avatar Oct 31 '22 07:10 zees98

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.

OutdatedGuy avatar Oct 31 '22 15:10 OutdatedGuy

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!

renkelvin avatar Nov 01 '22 17:11 renkelvin

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

jhoanarango avatar Nov 01 '22 18:11 jhoanarango

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:

  1. Point your pod dependency to the dev branch with pod 'FirebaseAuth', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'fix-apns-16'.
  2. Manually apply the changes to local installed pod files.
  3. Choose branch 'fix-apns-16' when add firebase-ios-sdk as package dependency.

Thanks!

renkelvin avatar Nov 01 '22 20:11 renkelvin

@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.

Screenshot 2022-11-01 at 4 36 47 PM

Any ideas?

jhoanarango avatar Nov 01 '22 20:11 jhoanarango

@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.

Screenshot 2022-11-01 at 4 36 47 PM

Any ideas?

Not sure. Do you use these Firebase products as well? Seems unrelated to the changes I'm making.

renkelvin avatar Nov 02 '22 07:11 renkelvin

@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. Screenshot 2022-11-01 at 4 36 47 PM 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.

jhoanarango avatar Nov 02 '22 16:11 jhoanarango

@renkelvin , works like a charm.. any ideas as to when it will be released?

jhoanarango avatar Nov 02 '22 18:11 jhoanarango

@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.

renkelvin avatar Nov 02 '22 21:11 renkelvin

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.

SaudElabdullah avatar Nov 04 '22 15:11 SaudElabdullah

Any way to push this release sooner?

ashtoncofer avatar Nov 04 '22 18:11 ashtoncofer

@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.

jhoanarango avatar Nov 04 '22 18:11 jhoanarango

@renkelvin Will this go to 10.2.0 release?

charlotteliang avatar Nov 07 '22 17:11 charlotteliang

@renkelvin Will this go to 10.2.0 release?

Yeah.

renkelvin avatar Nov 07 '22 18:11 renkelvin

@renkelvin @rosalyntan Would that be just https://github.com/firebase/firebase-ios-sdk/pull/10426 PR? Can you update CHANGELOG for the release?

charlotteliang avatar Nov 07 '22 18:11 charlotteliang

Yes.

CHANGELOG updated here https://github.com/firebase/firebase-ios-sdk/pull/10457

renkelvin avatar Nov 07 '22 18:11 renkelvin

Same for me. Looking forward to 10.2.0

devkayumov avatar Nov 08 '22 17:11 devkayumov

confirmed as working 🚀 thanks @renkelvin

kevb10 avatar Dec 01 '22 18:12 kevb10