Skip to content

Remove unnecessary notification flag #1993

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

Merged
merged 3 commits into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Example/Core/Tests/FIRAppTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

@interface FIRApp (TestInternal)

@property(nonatomic) BOOL alreadySentConfigureNotification;
@property(nonatomic) BOOL alreadySentDeleteNotification;

+ (void)resetApps;
- (instancetype)initInstanceWithName:(NSString *)name options:(FIROptions *)options;
- (BOOL)configureCore;
Expand Down Expand Up @@ -98,7 +95,6 @@ - (void)testConfigure {
XCTAssertEqualObjects(self.app.name, kFIRDefaultAppName);
XCTAssertEqualObjects(self.app.options.clientID, kClientID);
XCTAssertTrue([FIRApp allApps].count == 1);
XCTAssertTrue(self.app.alreadySentConfigureNotification);

// Test if options is nil
id optionsClassMock = OCMClassMock([FIROptions class]);
Expand Down Expand Up @@ -268,7 +264,6 @@ - (void)testDeleteApp {
}];

OCMVerifyAll(self.observerMock);
XCTAssertTrue(self.app.alreadySentDeleteNotification);
XCTAssertTrue([FIRApp allApps].count == 0);
}

Expand Down
37 changes: 7 additions & 30 deletions Firebase/Core/FIRApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@

@interface FIRApp ()

@property(nonatomic) BOOL alreadySentConfigureNotification;

@property(nonatomic) BOOL alreadySentDeleteNotification;

#ifdef DEBUG
@property(nonatomic) BOOL alreadyOutputDataCollectionFlag;
#endif // DEBUG
Expand Down Expand Up @@ -147,22 +143,13 @@ + (void)configureWithOptions:(FIROptions *)options {
+ (void)configureDefaultAppWithOptions:(FIROptions *)options
sendingNotifications:(BOOL)sendNotifications {
if (sDefaultApp) {
// FIRApp sets up FirebaseAnalytics and does plist validation, but does not cause it
// to fire notifications. So, if the default app already exists, but has not sent out
// configuration notifications, then continue re-initializing it.
if (!sendNotifications || sDefaultApp.alreadySentConfigureNotification) {
[NSException raise:kFirebaseCoreErrorDomain
format:@"Default app has already been configured."];
}
[NSException raise:kFirebaseCoreErrorDomain format:@"Default app has already been configured."];
}
@synchronized(self) {
FIRLogDebug(kFIRLoggerCore, @"I-COR000001", @"Configuring the default app.");
sDefaultApp = [[FIRApp alloc] initInstanceWithName:kFIRDefaultAppName options:options];
[FIRApp addAppToAppDictionary:sDefaultApp];
if (!sDefaultApp.alreadySentConfigureNotification && sendNotifications) {
[FIRApp sendNotificationsToSDKs:sDefaultApp];
sDefaultApp.alreadySentConfigureNotification = YES;
}
[FIRApp sendNotificationsToSDKs:sDefaultApp];
}
}

Expand Down Expand Up @@ -196,10 +183,7 @@ + (void)configureWithName:(NSString *)name options:(FIROptions *)options {
FIRLogDebug(kFIRLoggerCore, @"I-COR000002", @"Configuring app named %@", name);
FIRApp *app = [[FIRApp alloc] initInstanceWithName:name options:options];
[FIRApp addAppToAppDictionary:app];
if (!app.alreadySentConfigureNotification) {
[FIRApp sendNotificationsToSDKs:app];
app.alreadySentConfigureNotification = YES;
}
[FIRApp sendNotificationsToSDKs:app];
}
}

Expand Down Expand Up @@ -259,13 +243,10 @@ - (void)deleteApp:(FIRAppVoidBoolCallback)completion {
if ([self.name isEqualToString:kFIRDefaultAppName]) {
sDefaultApp = nil;
}
if (!self.alreadySentDeleteNotification) {
NSDictionary *appInfoDict = @{kFIRAppNameKey : self.name};
[[NSNotificationCenter defaultCenter] postNotificationName:kFIRAppDeleteNotification
object:[self class]
userInfo:appInfoDict];
self.alreadySentDeleteNotification = YES;
}
NSDictionary *appInfoDict = @{kFIRAppNameKey : self.name};
[[NSNotificationCenter defaultCenter] postNotificationName:kFIRAppDeleteNotification
object:[self class]
userInfo:appInfoDict];
completion(YES);
} else {
FIRLogError(kFIRLoggerCore, @"I-COR000007", @"App does not exist.");
Expand Down Expand Up @@ -296,10 +277,6 @@ - (instancetype)initInstanceWithName:(NSString *)name options:(FIROptions *)opti
_options.editingLocked = YES;
_isDefaultApp = [name isEqualToString:kFIRDefaultAppName];
_container = [[FIRComponentContainer alloc] initWithApp:self];

FIRApp *app = sAllApps[name];
_alreadySentConfigureNotification = app.alreadySentConfigureNotification;
_alreadySentDeleteNotification = app.alreadySentDeleteNotification;
}
return self;
}
Expand Down