Skip to content

Commit 13e895a

Browse files
Googlera-maurice
authored andcommitted
Fix for an exception in firebase::auth::VerifyPhoneNumber for applications recreating app instances.
Fix is to plumb clientID through the PlatformOptions to AppOptions (and vice versa) on iOS. The lack of a configured clientID was causing a NSInternalInconsistencyException in FIROAuthProvider getCredentialWithUIDelegate. PiperOrigin-RevId: 262248021
1 parent 0b4d39f commit 13e895a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

app/src/app_ios.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ static void PlatformOptionsToAppOptions(FIROptions* platform_options,
8585
NSString* value = platform_options.projectID;
8686
if (value) app_options->set_project_id(value.UTF8String);
8787
}
88+
if (!strlen(app_options->client_id())) {
89+
const char* value = platform_options.clientID.UTF8String;
90+
if (value) app_options->set_client_id(value);
91+
}
8892
}
8993

9094
// Copy AppOptions into a FIROptions instance.
@@ -115,6 +119,9 @@ static void PlatformOptionsToAppOptions(FIROptions* platform_options,
115119
if (strlen(app_options.project_id())) {
116120
platform_options.projectID = @(app_options.project_id());
117121
}
122+
if (strlen(app_options.client_id())) {
123+
platform_options.clientID = @(app_options.client_id());
124+
}
118125
return platform_options;
119126
}
120127

app/src/include/firebase/app.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,18 @@ class AppOptions {
291291
/// </SWIG>
292292
const char* project_id() const { return project_id_.c_str(); }
293293

294+
#if INTERNAL_EXPERIMENTAL
295+
/// @brief set the iOS client ID.
296+
///
297+
/// This is the clientID in the GoogleService-Info.plist.
298+
void set_client_id(const char* client_id) { client_id_ = client_id; }
299+
300+
/// @brief Get the iOS client ID.
301+
///
302+
/// This is the client_id in the GoogleService-Info.plist.
303+
const char* client_id() const { return client_id_.c_str(); }
304+
#endif // INTERNAL_EXPERIMENTAL
305+
294306
#ifdef INTERNAL_EXPERIMENTAL
295307
/// @brief Set the Android or iOS client project name.
296308
///
@@ -412,6 +424,8 @@ class AppOptions {
412424
std::string api_key_;
413425
/// ID of the app.
414426
std::string app_id_;
427+
/// ClientID of the app.
428+
std::string client_id_;
415429
/// Database root URL.
416430
std::string database_url_;
417431
/// Google analytics tracking ID.

0 commit comments

Comments
 (0)