Skip to content

Commit f1725c9

Browse files
committed
Use the default option's project id if not provided.
FIS on iOS (and soon Android) requires that the project id be set, which prevents Apps from being created without it. To prevent potential problems that developers might face, fall back to the default App's project id when creating additional apps. PiperOrigin-RevId: 295176371
1 parent 16c9cf9 commit f1725c9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

app/src/app_options.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ bool AppOptions::PopulateRequiredWithDefaults(
179179
JNIEnv* jni_env, jobject activity
180180
#endif // FIREBASE_PLATFORM_ANDROID
181181
) {
182-
// Populate App ID and API key from the default options if they're not
183-
// specified.
184-
if (app_id_.empty() || api_key_.empty()) {
182+
// Populate App ID, API key, and Project ID from the default options if
183+
// they're not specified.
184+
if (app_id_.empty() || api_key_.empty() || project_id_.empty()) {
185185
AppOptions default_options;
186186
if (AppOptions::LoadDefault(&default_options
187187
#if FIREBASE_PLATFORM_ANDROID
@@ -190,13 +190,15 @@ bool AppOptions::PopulateRequiredWithDefaults(
190190
)) {
191191
if (app_id_.empty()) app_id_ = default_options.app_id_;
192192
if (api_key_.empty()) api_key_ = default_options.api_key_;
193+
if (project_id_.empty()) project_id_ = default_options.project_id_;
193194
} else {
194195
LogError("Failed to load default options when attempting to populate "
195196
"missing fields");
196197
}
197198
}
198-
if (app_id_.empty() || api_key_.empty()) {
199-
LogError("App ID and API key must be specified in App options.");
199+
if (app_id_.empty() || api_key_.empty() || project_id_.empty()) {
200+
LogError(
201+
"App ID, API key, and Project ID must be specified in App options.");
200202
return false;
201203
}
202204
return true;

0 commit comments

Comments
 (0)