-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap diagnostics notification in collection flag check. #1979
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,13 +107,19 @@ @implementation FIRApp | |
+ (void)configure { | ||
FIROptions *options = [FIROptions defaultOptions]; | ||
if (!options) { | ||
[[NSNotificationCenter defaultCenter] | ||
postNotificationName:kFIRAppDiagnosticsNotification | ||
object:nil | ||
userInfo:@{ | ||
kFIRAppDiagnosticsConfigurationTypeKey : @(FIRConfigTypeCore), | ||
kFIRAppDiagnosticsErrorKey : [FIRApp errorForMissingOptions] | ||
}]; | ||
// Read the Info.plist to see if the flag is set. At this point we can't check any user defaults | ||
// since the app isn't configured at all, so only rely on the Info.plist value. | ||
NSNumber *collectionEnabledPlistValue = [[self class] readDataCollectionSwitchFromPlist]; | ||
if (!collectionEnabledPlistValue || [collectionEnabledPlistValue boolValue]) { | ||
[[NSNotificationCenter defaultCenter] | ||
postNotificationName:kFIRAppDiagnosticsNotification | ||
object:nil | ||
userInfo:@{ | ||
kFIRAppDiagnosticsConfigurationTypeKey : @(FIRConfigTypeCore), | ||
kFIRAppDiagnosticsErrorKey : [FIRApp errorForMissingOptions] | ||
}]; | ||
} | ||
|
||
[NSException raise:kFirebaseCoreErrorDomain | ||
format: | ||
@"`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find " | ||
|
@@ -274,13 +280,15 @@ + (void)addAppToAppDictionary:(FIRApp *)app { | |
} | ||
if ([app configureCore]) { | ||
sAllApps[app.name] = app; | ||
[[NSNotificationCenter defaultCenter] | ||
postNotificationName:kFIRAppDiagnosticsNotification | ||
object:nil | ||
userInfo:@{ | ||
kFIRAppDiagnosticsConfigurationTypeKey : @(FIRConfigTypeCore), | ||
kFIRAppDiagnosticsFIRAppKey : app | ||
}]; | ||
if ([app isDataCollectionDefaultEnabled]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like this should only be done in configureCore - but that could be a separate refactor? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll try to refactor it now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
[[NSNotificationCenter defaultCenter] | ||
postNotificationName:kFIRAppDiagnosticsNotification | ||
object:nil | ||
userInfo:@{ | ||
kFIRAppDiagnosticsConfigurationTypeKey : @(FIRConfigTypeCore), | ||
kFIRAppDiagnosticsFIRAppKey : app | ||
}]; | ||
} | ||
} else { | ||
[NSException raise:kFirebaseCoreErrorDomain | ||
format: | ||
|
@@ -317,7 +325,7 @@ - (void)getTokenForcingRefresh:(BOOL)forceRefresh withCallback:(FIRTokenCallback | |
- (BOOL)configureCore { | ||
[self checkExpectedBundleID]; | ||
if (![self isAppIDValid]) { | ||
if (_options.usingOptionsFromDefaultPlist) { | ||
if (_options.usingOptionsFromDefaultPlist && [self isDataCollectionDefaultEnabled]) { | ||
[[NSNotificationCenter defaultCenter] | ||
postNotificationName:kFIRAppDiagnosticsNotification | ||
object:nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does OCMOCK_ANY include nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will test to see if that's the case!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, it does include nil. I'll make sure we don't duplicate this elsewhere in a different PR (grabbed this from a different location).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.