firebase / FirebaseUI-iOS

iOS UI bindings for Firebase.
Apache License 2.0
1.5k stars 467 forks source link

[Phone Auth] Building with Xcode 14.3.X, displays wrong country code #1155

Closed zrn-ns closed 9 months ago

zrn-ns commented 11 months ago

Welcome to FirebaseUI and thanks for submitting an issue!

Please take a look at open issues, as well as resolved issues, to see if your issue is either already being addressed, or has been solved by someone else.

If your issue concerns the CocoaPods error, "...transitive dependencies that include static binaries", please take a look at any of the following issues and see if your problem is solved: #48, #47, #46, #34, #23.

If not, please feel free to fill in the following info so we can help faster!

Step 1: Are you in the right place?

Step 2: Describe your environment

Step 3: Describe the problem:

First of all, I would like to thank you for developing this wonderful framework.

Steps to reproduce:

  1. Implement sign-in with phone number feature with FirebaseUI-Auth.
  2. Build application with Xcode 14.3.X .
  3. Run application on iPhone sold in countries other than the United States.

Observed Results:

Expected Results:

Using Xcode 14.2, This problem does not occur and the default country code is decided by the carrier of device.

Relevant Code:

Other Info

First of all, it seems that you can get a country code (like as +1, +81) by accessing CTCarrier.isoCountryCode of CoreTelephony, but this API was deprecated in iOS16, and from 16.4, a fixed value is returned.

https://developer.apple.com/forums/thread/714876

iOS 16 CTCarrier deprecation Core Telephony Deprecations CTCarrier, a deprecated API, returns static values for apps that are built with the iOS 16.4 SDK or later.

I found that the process to get the default country code (FUICountryCodes.m#127) accesses CTCarrier.isoCountryCode, so this is likely the cause.

https://github.com/firebase/FirebaseUI-iOS/blob/4dad85472124ce78aca8d20e6a2c8658357e1d2e/FirebasePhoneAuthUI/Sources/FUICountryCodes.m#L127

The standard iOS API has been discontinued and may be difficult to fix this problem, but I would appreciate it if you could fix it.

Best regards.

zrn-ns commented 11 months ago

If it is difficult to obtain a default country code, another option is to allow developers to set an arbitrary country code as default.

morganchen12 commented 10 months ago

Hi @zrn-ns, would something like this be suitable? https://github.com/firebase/FirebaseUI-iOS/pull/1159

zrn-ns commented 10 months ago

@morganchen12 Thank you for implementing!

It needs to be fixed in that setting a code like "JP" to defaultCountryCode causes a crash, but the way you implemented it is exactly what I was looking for.

morganchen12 commented 9 months ago

Fixed the crash. This API will be released today.

zrn-ns commented 9 months ago

@morganchen12 Thank you! 🎉 🎉 🎉