@@ -107,13 +107,19 @@ @implementation FIRApp
107
107
+ (void )configure {
108
108
FIROptions *options = [FIROptions defaultOptions ];
109
109
if (!options) {
110
- [[NSNotificationCenter defaultCenter ]
111
- postNotificationName: kFIRAppDiagnosticsNotification
112
- object: nil
113
- userInfo: @{
114
- kFIRAppDiagnosticsConfigurationTypeKey : @(FIRConfigTypeCore),
115
- kFIRAppDiagnosticsErrorKey : [FIRApp errorForMissingOptions ]
116
- }];
110
+ // Read the Info.plist to see if the flag is set. At this point we can't check any user defaults
111
+ // since the app isn't configured at all, so only rely on the Info.plist value.
112
+ NSNumber *collectionEnabledPlistValue = [[self class ] readDataCollectionSwitchFromPlist ];
113
+ if (!collectionEnabledPlistValue || [collectionEnabledPlistValue boolValue ]) {
114
+ [[NSNotificationCenter defaultCenter ]
115
+ postNotificationName: kFIRAppDiagnosticsNotification
116
+ object: nil
117
+ userInfo: @{
118
+ kFIRAppDiagnosticsConfigurationTypeKey : @(FIRConfigTypeCore),
119
+ kFIRAppDiagnosticsErrorKey : [FIRApp errorForMissingOptions ]
120
+ }];
121
+ }
122
+
117
123
[NSException raise: kFirebaseCoreErrorDomain
118
124
format:
119
125
@" `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find "
@@ -274,13 +280,6 @@ + (void)addAppToAppDictionary:(FIRApp *)app {
274
280
}
275
281
if ([app configureCore ]) {
276
282
sAllApps [app.name] = app;
277
- [[NSNotificationCenter defaultCenter ]
278
- postNotificationName: kFIRAppDiagnosticsNotification
279
- object: nil
280
- userInfo: @{
281
- kFIRAppDiagnosticsConfigurationTypeKey : @(FIRConfigTypeCore),
282
- kFIRAppDiagnosticsFIRAppKey : app
283
- }];
284
283
} else {
285
284
[NSException raise: kFirebaseCoreErrorDomain
286
285
format:
@@ -317,7 +316,7 @@ - (void)getTokenForcingRefresh:(BOOL)forceRefresh withCallback:(FIRTokenCallback
317
316
- (BOOL )configureCore {
318
317
[self checkExpectedBundleID ];
319
318
if (![self isAppIDValid ]) {
320
- if (_options.usingOptionsFromDefaultPlist ) {
319
+ if (_options.usingOptionsFromDefaultPlist && [ self isDataCollectionDefaultEnabled ] ) {
321
320
[[NSNotificationCenter defaultCenter ]
322
321
postNotificationName: kFIRAppDiagnosticsNotification
323
322
object: nil
@@ -329,6 +328,16 @@ - (BOOL)configureCore {
329
328
return NO ;
330
329
}
331
330
331
+ if ([self isDataCollectionDefaultEnabled ]) {
332
+ [[NSNotificationCenter defaultCenter ]
333
+ postNotificationName: kFIRAppDiagnosticsNotification
334
+ object: nil
335
+ userInfo: @{
336
+ kFIRAppDiagnosticsConfigurationTypeKey : @(FIRConfigTypeCore),
337
+ kFIRAppDiagnosticsFIRAppKey : self
338
+ }];
339
+ }
340
+
332
341
#if TARGET_OS_IOS
333
342
// Initialize the Analytics once there is a valid options under default app. Analytics should
334
343
// always initialize first by itself before the other SDKs.
0 commit comments