Skip to content
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
1 change: 1 addition & 0 deletions FirebaseRemoteConfig/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 9.3.0
- [changed] Arrays and Dictionaries are now supported when initializing defaults from a
plist. (#8306)
- [fixed] Activate calls will only update experiment data for `firebase` namespace to ensure correct experiment exposures. (#9972)

# 9.0.0
- [changed] The `remoteConfig()` singleton now throws an exception when called before
Expand Down
16 changes: 14 additions & 2 deletions FirebaseRemoteConfig/Sources/FIRRemoteConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,25 @@ - (void)activateWithCompletion:(FIRRemoteConfigActivateChangeCompletion)completi
strongSelf->_settings.lastApplyTimeInterval = [[NSDate date] timeIntervalSince1970];
FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000069", @"Config activated.");
[strongSelf->_configContent activatePersonalization];
[strongSelf->_configExperiment updateExperimentsWithHandler:^(NSError *_Nullable error) {

// Update experiments only for 3p namespace
NSString *namespace = [strongSelf->_FIRNamespace
substringToIndex:[strongSelf->_FIRNamespace rangeOfString:@":"].location];
if ([namespace isEqualToString:FIRNamespaceGoogleMobilePlatform]) {
[strongSelf->_configExperiment updateExperimentsWithHandler:^(NSError *_Nullable error) {
if (completion) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
completion(YES, nil);
});
}
}];
} else {
if (completion) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
completion(YES, nil);
});
}
}];
}
};
dispatch_async(_queue, applyBlock);
}
Expand Down
53 changes: 34 additions & 19 deletions FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -467,48 +467,63 @@ - (void)testEnumeratingConfigResults {
}];
}

- (void)testFetch3pNamespaceUpdatesExperiments {
- (void)testFetchAndActivate3pNamespaceUpdatesExperiments {
[[_experimentMock expect] updateExperimentsWithResponse:[OCMArg any]];

XCTestExpectation *expectation = [self
expectationWithDescription:
[NSString
stringWithFormat:@"Fetch call for 'firebase' namespace updates experiment data"]];
expectationWithDescription:[NSString stringWithFormat:@"FetchAndActivate call for 'firebase' "
@"namespace updates experiment data"]];
XCTAssertEqual(_configInstances[RCNTestRCInstanceDefault].lastFetchStatus,
FIRRemoteConfigFetchStatusNoFetchYet);
FIRRemoteConfigFetchCompletion fetchCompletion =
^void(FIRRemoteConfigFetchStatus status, NSError *error) {

FIRRemoteConfigFetchAndActivateCompletion fetchAndActivateCompletion =
^void(FIRRemoteConfigFetchAndActivateStatus status, NSError *error) {
XCTAssertEqual(status, FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote);
XCTAssertNil(error);

XCTAssertEqual(self->_configInstances[RCNTestRCInstanceDefault].lastFetchStatus,
FIRRemoteConfigFetchStatusSuccess);
XCTAssertNil(error);
XCTAssertNotNil(self->_configInstances[RCNTestRCInstanceDefault].lastFetchTime);
XCTAssertGreaterThan(
self->_configInstances[RCNTestRCInstanceDefault].lastFetchTime.timeIntervalSince1970, 0,
@"last fetch time interval should be set.");
[expectation fulfill];
};
[_configInstances[RCNTestRCInstanceDefault] fetchWithExpirationDuration:43200
completionHandler:fetchCompletion];

[_configInstances[RCNTestRCInstanceDefault]
fetchAndActivateWithCompletionHandler:fetchAndActivateCompletion];
[self waitForExpectationsWithTimeout:_expectationTimeout
handler:^(NSError *error) {
XCTAssertNil(error);
}];
}

- (void)testFetchOtherNamespaceDoesntUpdateExperiments {
- (void)testFetchAndActivateOtherNamespaceDoesntUpdateExperiments {
[[_experimentMock reject] updateExperimentsWithResponse:[OCMArg any]];

XCTestExpectation *expectation =
[self expectationWithDescription:
[NSString stringWithFormat:@"Fetch call for namespace other than 'firebase' "
@"doesn't update experiment data"]];
XCTestExpectation *expectation = [self
expectationWithDescription:
[NSString stringWithFormat:@"FetchAndActivate call for namespace other than 'firebase' "
@"doesn't update experiment data"]];
XCTAssertEqual(_configInstances[RCNTestRCInstanceSecondNamespace].lastFetchStatus,
FIRRemoteConfigFetchStatusNoFetchYet);
FIRRemoteConfigFetchCompletion fetchCompletion =
^void(FIRRemoteConfigFetchStatus status, NSError *error) {

FIRRemoteConfigFetchAndActivateCompletion fetchAndActivateCompletion =
^void(FIRRemoteConfigFetchAndActivateStatus status, NSError *error) {
XCTAssertEqual(status, FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote);
XCTAssertNil(error);

XCTAssertEqual(self->_configInstances[RCNTestRCInstanceSecondNamespace].lastFetchStatus,
FIRRemoteConfigFetchStatusSuccess);
XCTAssertNil(error);
XCTAssertNotNil(self->_configInstances[RCNTestRCInstanceSecondNamespace].lastFetchTime);
XCTAssertGreaterThan(self->_configInstances[RCNTestRCInstanceSecondNamespace]
.lastFetchTime.timeIntervalSince1970,
0, @"last fetch time interval should be set.");
[expectation fulfill];
};
[_configInstances[RCNTestRCInstanceSecondNamespace] fetchWithExpirationDuration:43200
completionHandler:fetchCompletion];

[_configInstances[RCNTestRCInstanceSecondNamespace]
fetchAndActivateWithCompletionHandler:fetchAndActivateCompletion];
[self waitForExpectationsWithTimeout:_expectationTimeout
handler:^(NSError *error) {
XCTAssertNil(error);
Expand Down