FirebaseUI-iOS icon indicating copy to clipboard operation
FirebaseUI-iOS copied to clipboard

Token Mismatch for Firebase Auth on MacCatalyst (works fine on iOS)

Open ZComwiz opened this issue 4 years ago • 10 comments

Step 0: Are you in the right place?

Yes.

[REQUIRED] Step 1: Describe your environment

  • Xcode version 12.1
  • Firebase SDK version: 7.1.0
  • Installation method: CocoaPods 1.10.0
  • Firebase Component: Auth

[REQUIRED] Step 2: Describe the problem

When using FirebaseUI-Auth for iOS on Mac Catalyst to sign in via Text Message Auth it returns an alert: "Something went wrong. Please try again."

The console prints out an optional statement reading: Token Mismatch. The error does not occur on the iPhone or iPhone simulator.

>>> **Optional("Token mismatch")** 2020-11-24 00:25:51.231263+0200 App[46526:980525] startURLificationForContainer <FUIPrivacyAndTermsOfServiceView: 0x106abd000; baseClass = UITextView; frame = (10 0; 355 100); text = 'By tapping Verify Phone N...'; clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x600000ddfe10>; layer = <CALayer: 0x60000065ff20>; contentOffset: {0, 0}; contentSize: {355, 46}; adjustedContentInset: {0, 0, 0, 0}> (types 2) created operation <DDTextKitOperation: 0x108292e60> 2020-11-24 00:25:51.232836+0200 App[46526:980525] Cancelling operation for container <FUIPrivacyAndTermsOfServiceView: 0x106abd000; baseClass = UITextView; frame = (10 0; 355 100); text = 'By tapping Verify, you ar...'; clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x600000ddfe10>; layer = <CALayer: 0x60000065ff20>; contentOffset: {0, 0}; contentSize: {355, 52}; adjustedContentInset: {0, 0, 0, 0}>. 2020-11-24 00:25:51.232854+0200 App[46526:980525] operation 0x108292e60 2020-11-24 00:25:51.232928+0200 App[46526:980525] startURLificationForContainer <FUIPrivacyAndTermsOfServiceView: 0x106abd000; baseClass = UITextView; frame = (10 0; 355 100); text = 'By tapping Verify, you ar...'; clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x600000ddfe10>; layer = <CALayer: 0x60000065ff20>; contentOffset: {0, 0}; contentSize: {355, 52}; adjustedContentInset: {0, 0, 0, 0}> (types 2) created operation <DDTextKitOperation: 0x1082a1060> 2020-11-24 00:25:51.237299+0200 App[46526:980525] operation 0x108292e60 2020-11-24 00:25:51.237321+0200 App[46526:980525] operation 0x108292e60 is discarded 2020-11-24 00:25:51.237330+0200 App[46526:980525] Calling the completion block for 0x108292e60 2020-11-24 00:25:51.237348+0200 App[46526:980525] dispatchScanQueryCreationWithCompletionBlock of operation <DDTextKitOperation: 0x108292e60> completion block: success: 0 2020-11-24 00:25:51.237413+0200 App[46526:980525] operation 0x108292e60 2020-11-24 00:25:51.237423+0200 App[46526:980525] operation 0x108292e60 2020-11-24 00:25:51.237444+0200 App[46526:980525] operation 0x1082a1060 2020-11-24 00:25:51.237451+0200 App[46526:980525] really creating scan query in operation 0x1082a1060! 2020-11-24 00:25:51.237458+0200 App[46526:980525] operation 0x1082a1060 2020-11-24 00:25:51.237468+0200 App[46526:980525] 0x1082a1060 created scan query 0x6000017e4400 2020-11-24 00:25:51.237475+0200 App[46526:980525] Calling the completion block for 0x1082a1060 2020-11-24 00:25:51.237487+0200 App[46526:980525] dispatchScanQueryCreationWithCompletionBlock of operation <DDTextKitOperation: 0x1082a1060> completion block: success: 1 2020-11-24 00:25:51.237560+0200 App[46526:982252] operation 0x1082a1060 2020-11-24 00:25:51.237942+0200 App[46526:982252] Firing completion block for <DDTextKitOperation: 0x1082a1060> 2020-11-24 00:25:51.238342+0200 App[46526:980525] <DDTextKitOperation: 0x1082a1060> 2020-11-24 00:25:51.238416+0200 App[46526:980525] operation 0x1082a1060 2020-11-24 00:25:51.238429+0200 App[46526:980525] operation 0x1082a1060 2020-11-24 00:25:51.630754+0200 App[46526:980525] Warning: Attempt to present <UINavigationController: 0x106821400> on <UINavigationController: 0x108827c00> which is already presenting <UINavigationController: 0x1068cae00>

Steps to reproduce:

Try typing in a number to MacCatalyst app on FirebaseUI v.9.0.0 (it didn't work on previous releases either) Get Above Error.

Relevant Code:

  UIViewController *vc = [[[UIApplication sharedApplication] keyWindow] rootViewController];
    FUIAuth *auth = [FUIAuth defaultAuthUI];
    auth.TOSURL = [NSURL URLWithString:@"https://app.com/terms"];
    auth.privacyPolicyURL = [NSURL URLWithString:@"https://app.com/privacy"];

    auth.delegate = [PFFirebaseDelegate sharedInstance];
    FUIPhoneAuth *phoneAuth = [[FUIPhoneAuth alloc] initWithAuthUI:auth];
    auth.providers = @[phoneAuth];
    [phoneAuth signInWithPresentingViewController:vc];

ZComwiz avatar Nov 23 '20 22:11 ZComwiz

@paulb777 any clue what could cause that? Does Mac require a separate APNs upload to Firebase?

ZComwiz avatar Nov 24 '20 15:11 ZComwiz

@ryanwilson any idea where I should start investigating? I've looked into changing the APNS mode in the entitlements, made sure the bundleID was the same.. Anything in the provisioning profile used which might be at play?

ZComwiz avatar Nov 24 '20 22:11 ZComwiz

Looks like this is a FirebaseUI issue, I've transferred it there. Likely a duplicate as well, check out the notes here: https://github.com/firebase/FirebaseUI-iOS/issues/301#issuecomment-311200176

Hope that helps, please share what you tried and if it worked or you're still seeing the issue.

ryanwilson avatar Nov 24 '20 22:11 ryanwilson

@ryanwilson I got it to work in debug mode by switching the entitlement file to development and the AppDelegate setup to .sandbox. However, switching it to Production and the AppDelegate setup to .prod doesn't work. I then archived the project and dug into the outputted app file and ran it and it still doesn't work in production. I wouldn't want to release to the App Store and have it break..

Is there harm in keeping the APNS in .sandbox mode while in production? Everything else is ready to ship! This is our last hurdle 🤞

ZComwiz avatar Nov 25 '20 03:11 ZComwiz

Is there harm in keeping the APNS in .sandbox mode while in production? Everything else is ready to ship! This is our last hurdle 🤞

cc @rosalyntan - can you please take a look and help find the answer here related to phone auth?

ryanwilson avatar Nov 25 '20 14:11 ryanwilson

We're tracking this internally at b/174266354

strom2357 avatar Nov 25 '20 22:11 strom2357

Since 3 days (maybe since Xcode 14) "Token Mismatch" started appearing for me out of the blue for phone auth (it used to work before and also does not work when i go back to commits where it used to work). So far it appears on any simulators. I managed to authenticate on iOS 16 simulators initially.

nidegen avatar Oct 11 '22 14:10 nidegen

My case is actually https://github.com/firebase/firebase-ios-sdk/issues/10214

I think on macCatalyst it must be a smililar issue that push notification is unexpectedly available..

nidegen avatar Oct 14 '22 19:10 nidegen

@nidegen— Firebase Phone Auth has been a nightmare lately with many random internal errors and now this Token Mismatch for MacCatalyst even with 10.2.0. 🤯

ZComwiz avatar Nov 21 '22 13:11 ZComwiz

Hey all, sorry for the delay. Can you check to see it if works now that https://github.com/firebase/firebase-ios-sdk/issues/10214 has been resolved?

morganchen12 avatar Feb 08 '23 23:02 morganchen12