Skip to content

Commit 563232c

Browse files
authored
Revert "Realtime rc no change (#10188)" (#10346)
This reverts commit abe7939. In part of implementing a different solution.
1 parent 29bb9be commit 563232c

File tree

7 files changed

+40
-133
lines changed

7 files changed

+40
-133
lines changed

FirebaseRemoteConfig/Sources/FIRRemoteConfig.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ - (void)fetchWithExpirationDuration:(NSTimeInterval)expirationDuration
250250
completionHandlerCopy = [completionHandler copy];
251251
}
252252
[_configFetch fetchConfigWithExpirationDuration:expirationDuration
253-
completionHandler:completionHandlerCopy
254-
excludeEtagHeaderForRealtime:false];
253+
completionHandler:completionHandlerCopy];
255254
}
256255

257256
#pragma mark - fetchAndActivate

FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,9 @@ typedef void (^RCNConfigFetcherCompletion)(NSData *data, NSURLResponse *response
4646

4747
/// Fetches config data keyed by namespace. Completion block will be called on the main queue.
4848
/// @param expirationDuration Expiration duration, in seconds.
49-
/// @param excludeEtagHeaderForRealtime Needed for fetches from Realtime when an UPDATE response is
50-
/// required
5149
/// @param completionHandler Callback handler.
5250
- (void)fetchConfigWithExpirationDuration:(NSTimeInterval)expirationDuration
53-
completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler
54-
excludeEtagHeaderForRealtime:(bool)excludeEtagHeaderForRealtime;
51+
completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler;
5552

5653
/// Add the ability to update NSURLSession's timeout after a session has already been created.
5754
- (void)recreateNetworkSession;

FirebaseRemoteConfig/Sources/RCNConfigFetch.m

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ - (void)dealloc {
127127
#pragma mark - Fetch Config API
128128

129129
- (void)fetchConfigWithExpirationDuration:(NSTimeInterval)expirationDuration
130-
completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler
131-
excludeEtagHeaderForRealtime:(bool)excludeEtagHeaderForRealtime {
130+
completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler {
132131
// Note: We expect the googleAppID to always be available.
133132
BOOL hasDeviceContextChanged =
134133
FIRRemoteConfigHasDeviceContextChanged(_settings.deviceContext, _options.googleAppID);
@@ -192,8 +191,7 @@ - (void)fetchConfigWithExpirationDuration:(NSTimeInterval)expirationDuration
192191
withError:error];
193192
}
194193
strongSelf->_settings.isFetchInProgress = YES;
195-
[strongSelf refreshInstallationsTokenWithCompletionHandler:completionHandler
196-
excludeEtagHeaderForRealtime:excludeEtagHeaderForRealtime];
194+
[strongSelf refreshInstallationsTokenWithCompletionHandler:completionHandler];
197195
});
198196
}
199197

@@ -205,8 +203,7 @@ - (NSString *)FIRAppNameFromFullyQualifiedNamespace {
205203
/// Refresh installation ID token before fetching config. installation ID is now mandatory for fetch
206204
/// requests to work.(b/14751422).
207205
- (void)refreshInstallationsTokenWithCompletionHandler:
208-
(FIRRemoteConfigFetchCompletion)completionHandler
209-
excludeEtagHeaderForRealtime:(bool)excludeEtagHeaderForRealtime {
206+
(FIRRemoteConfigFetchCompletion)completionHandler {
210207
FIRInstallations *installations = [FIRInstallations
211208
installationsWithApp:[FIRApp appNamed:[self FIRAppNameFromFullyQualifiedNamespace]]];
212209
if (!installations || !_options.GCMSenderID) {
@@ -286,8 +283,7 @@ - (void)refreshInstallationsTokenWithCompletionHandler:
286283

287284
FIRLogInfo(kFIRLoggerRemoteConfig, @"I-RCN000022", @"Success to get iid : %@.",
288285
strongSelfQueue->_settings.configInstallationsIdentifier);
289-
[strongSelf doFetchCall:completionHandler
290-
excludeEtagHeaderForRealtime:excludeEtagHeaderForRealtime];
286+
[strongSelf doFetchCall:completionHandler];
291287
});
292288
}];
293289
};
@@ -296,13 +292,10 @@ - (void)refreshInstallationsTokenWithCompletionHandler:
296292
[installations authTokenWithCompletion:installationsTokenHandler];
297293
}
298294

299-
- (void)doFetchCall:(FIRRemoteConfigFetchCompletion)completionHandler
300-
excludeEtagHeaderForRealtime:(bool)excludeEtagHeaderForRealtime {
295+
- (void)doFetchCall:(FIRRemoteConfigFetchCompletion)completionHandler {
301296
[self getAnalyticsUserPropertiesWithCompletionHandler:^(NSDictionary *userProperties) {
302297
dispatch_async(self->_lockQueue, ^{
303-
[self fetchWithUserProperties:userProperties
304-
completionHandler:completionHandler
305-
excludeEtagHeaderForRealtime:excludeEtagHeaderForRealtime];
298+
[self fetchWithUserProperties:userProperties completionHandler:completionHandler];
306299
});
307300
}];
308301
}
@@ -329,8 +322,7 @@ - (void)reportCompletionOnHandler:(FIRRemoteConfigFetchCompletion)completionHand
329322
}
330323

331324
- (void)fetchWithUserProperties:(NSDictionary *)userProperties
332-
completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler
333-
excludeEtagHeaderForRealtime:(bool)excludeEtagHeaderForRealtime {
325+
completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler {
334326
FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000061", @"Fetch with user properties initiated.");
335327

336328
NSString *postRequestString = [_settings nextRequestWithUserProperties:userProperties];
@@ -523,10 +515,8 @@ - (void)fetchWithUserProperties:(NSDictionary *)userProperties
523515

524516
FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000061", @"Making remote config fetch.");
525517

526-
NSURLSessionDataTask *dataTask =
527-
[self URLSessionDataTaskWithContent:compressedContent
528-
completionHandler:fetcherCompletion
529-
excludeEtagHeaderForRealtime:excludeEtagHeaderForRealtime];
518+
NSURLSessionDataTask *dataTask = [self URLSessionDataTaskWithContent:compressedContent
519+
completionHandler:fetcherCompletion];
530520
[dataTask resume];
531521
}
532522

@@ -566,8 +556,7 @@ - (NSURLSession *)newFetchSession {
566556

567557
- (NSURLSessionDataTask *)URLSessionDataTaskWithContent:(NSData *)content
568558
completionHandler:
569-
(RCNConfigFetcherCompletion)fetcherCompletion
570-
excludeEtagHeaderForRealtime:(bool)excludeEtagHeaderForRealtime {
559+
(RCNConfigFetcherCompletion)fetcherCompletion {
571560
NSURL *URL = [NSURL URLWithString:[self constructServerURL]];
572561
FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000046", @"%@",
573562
[NSString stringWithFormat:@"Making config request: %@", [URL absoluteString]]);
@@ -586,7 +575,7 @@ - (NSURLSessionDataTask *)URLSessionDataTaskWithContent:(NSData *)content
586575
[URLRequest setValue:@"gzip" forHTTPHeaderField:kContentEncodingHeaderName];
587576
[URLRequest setValue:@"gzip" forHTTPHeaderField:kAcceptEncodingHeaderName];
588577
// Set the eTag from the last successful fetch, if available.
589-
if (_settings.lastETag && !excludeEtagHeaderForRealtime) {
578+
if (_settings.lastETag) {
590579
[URLRequest setValue:_settings.lastETag forHTTPHeaderField:kIfNoneMatchETagHeaderName];
591580
}
592581
[URLRequest setHTTPBody:content];

FirebaseRemoteConfig/Sources/RCNConfigRealtime.m

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,6 @@ - (void)fetchLatestConfig:(NSInteger)remainingAttempts targetVersion:(NSInteger)
420420
[strongSelf autoFetch:remainingAttempts - 1 targetVersion:targetVersion];
421421
}
422422
} else {
423-
/// If the template version is it's default value, 0, then we need to exclude the Etag from
424-
/// the fetch to get a response with the current template version.
425-
bool excludeEtagHeaderForRealtime =
426-
[[strongSelf->_configFetch templateVersionNumber] integerValue] == 0;
427423
[strongSelf->_configFetch
428424
fetchConfigWithExpirationDuration:0
429425
completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *error) {
@@ -455,8 +451,7 @@ - (void)fetchLatestConfig:(NSInteger)remainingAttempts targetVersion:(NSInteger)
455451
targetVersion:targetVersion];
456452
}
457453
}
458-
}
459-
excludeEtagHeaderForRealtime:excludeEtagHeaderForRealtime];
454+
}];
460455
}
461456
});
462457
}

FirebaseRemoteConfig/Tests/Unit/RCNPersonalizationTest.m

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@
3030
@interface RCNConfigFetch (ForTest)
3131
- (NSURLSessionDataTask *)URLSessionDataTaskWithContent:(NSData *)content
3232
completionHandler:
33-
(RCNConfigFetcherCompletion)fetcherCompletion
34-
excludeEtagHeaderForRealtime:(bool)excludeEtagHeaderForRealtime;
33+
(RCNConfigFetcherCompletion)fetcherCompletion;
3534

3635
- (void)fetchWithUserProperties:(NSDictionary *)userProperties
37-
completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler
38-
excludeEtagHeaderForRealtime:(bool)excludeEtagHeaderForRealtime;
36+
completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler;
3937
@end
4038

4139
@interface RCNPersonalizationTest : XCTestCase {
@@ -240,20 +238,16 @@ - (void)testRemoteConfigIntegration {
240238

241239
+ (id)mockFetchRequest {
242240
id configFetch = OCMClassMock([RCNConfigFetch class]);
243-
OCMStub([configFetch fetchConfigWithExpirationDuration:0
244-
completionHandler:OCMOCK_ANY
245-
excludeEtagHeaderForRealtime:false])
241+
OCMStub([configFetch fetchConfigWithExpirationDuration:0 completionHandler:OCMOCK_ANY])
246242
.ignoringNonObjectArgs()
247243
.andDo(^(NSInvocation *invocation) {
248244
__unsafe_unretained FIRRemoteConfigFetchCompletion handler;
249245
[invocation getArgument:&handler atIndex:3];
250-
[configFetch fetchWithUserProperties:[[NSDictionary alloc] init]
251-
completionHandler:handler
252-
excludeEtagHeaderForRealtime:false];
246+
[configFetch fetchWithUserProperties:[[NSDictionary alloc] init] completionHandler:handler];
253247
});
254-
OCMExpect([configFetch URLSessionDataTaskWithContent:[OCMArg any]
255-
completionHandler:[RCNPersonalizationTest mockResponseHandler]
256-
excludeEtagHeaderForRealtime:false])
248+
OCMExpect([configFetch
249+
URLSessionDataTaskWithContent:[OCMArg any]
250+
completionHandler:[RCNPersonalizationTest mockResponseHandler]])
257251
.andReturn(nil);
258252
return configFetch;
259253
}

0 commit comments

Comments
 (0)