Skip to content

Commit 6004f9c

Browse files
Revert "FitebaseInstallations: fix create FID race condition (#4576)" (#4598)
This reverts commit 89bd10f.
1 parent 3fb0ed0 commit 6004f9c

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

FirebaseInstallations/Source/Library/InstallationsIDController/FIRInstallationsIDController.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ - (instancetype)initWithGoogleAppID:(NSString *)appID
137137
#pragma mark - Get Installation.
138138

139139
- (FBLPromise<FIRInstallationsItem *> *)getInstallationItem {
140-
return [self mostRecentInstallationOperation]
141-
?: [self.getInstallationPromiseCache getExistingPendingOrCreateNewPromise];
140+
return [self.getInstallationPromiseCache getExistingPendingOrCreateNewPromise];
142141
}
143142

144143
- (FBLPromise<FIRInstallationsItem *> *)createGetInstallationItemPromise {
@@ -306,7 +305,7 @@ - (BOOL)doesRegistrationErrorRequireConfigChange:(NSError *)error {
306305
@"appName: %@",
307306
@(forceRefresh), self.appName);
308307

309-
return [self.getInstallationPromiseCache getExistingPendingOrCreateNewPromise]
308+
return [self getInstallationItem]
310309
.then(^FBLPromise<FIRInstallationsItem *> *(FIRInstallationsItem *installation) {
311310
return [self registerInstallationIfNeeded:installation];
312311
})
@@ -345,7 +344,7 @@ - (id)regenerateFIDOnRefreshTokenErrorIfNeeded:(NSError *)error {
345344
case FIRInstallationsAuthTokenHTTPCodeFIDNotFound:
346345
// The stored installation was damaged or blocked by the server.
347346
// Delete the stored installation then generate and register a new one.
348-
return [self getStoredInstallation]
347+
return [self getInstallationItem]
349348
.then(^FBLPromise<NSNull *> *(FIRInstallationsItem *installation) {
350349
return [self deleteInstallationLocally:installation];
351350
})

FirebaseInstallations/Source/Tests/Unit/FIRInstallationsIDControllerTests.m

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ - (void)testGetInstallationItem_WhenNoFIDAndNoIID_ThenFIDIsCreatedAndRegistered
177177
// 5.5. Verify registered installation was saved.
178178
OCMVerifyAll(self.mockInstallationsStore);
179179
OCMVerifyAll(self.mockIIDStore);
180-
OCMVerifyAll(self.mockAPIService);
181180
}
182181

183182
- (void)testGetInstallationItem_WhenThereIsIIDAndNoFIDNotDefaultApp_ThenIIDIsUsedAsFID {
@@ -334,17 +333,11 @@ - (void)testGetInstallationItem_WhenThereIsIIDAndNoFID_ThenFIDIsCreatedAndRegist
334333
- (void)testGetInstallationItem_WhenCalledSeveralTimes_OnlyOneOperationIsPerformed {
335334
// 1. Expect the installation to be requested from the store only once.
336335
FIRInstallationsItem *storedInstallation1 =
337-
[FIRInstallationsItem createUnregisteredInstallationItem];
336+
[FIRInstallationsItem createRegisteredInstallationItem];
338337
FBLPromise<FIRInstallationsItem *> *pendingStorePromise = [FBLPromise pendingPromise];
339338
OCMExpect([self.mockInstallationsStore installationForAppID:self.appID appName:self.appName])
340339
.andReturn(pendingStorePromise);
341340

342-
// 2. Expect Create FID API request to be sent once.
343-
FBLPromise<FIRInstallationsItem *> *registrationErrorPromise = [FBLPromise pendingPromise];
344-
[registrationErrorPromise reject:[FIRInstallationsErrorUtil APIErrorWithHTTPCode:400]];
345-
OCMExpect([self.mockAPIService registerInstallation:storedInstallation1])
346-
.andReturn(registrationErrorPromise);
347-
348341
// 3. Request installation n times
349342
NSInteger requestCount = 10;
350343
NSMutableArray *installationPromises = [NSMutableArray arrayWithCapacity:requestCount];

0 commit comments

Comments
 (0)