Skip to content

Commit 4dcf659

Browse files
authored
Migrate FetchAndActivate from deprecated implementation (#5617)
1 parent 819091b commit 4dcf659

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

FirebaseRemoteConfig/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1+
# Unreleased
2+
- [changed] Updated `fetchAndActivateWithCompletionHandler:` implementation to activate asynchronously. (#5617)
3+
14
# v4.4.11
25
- [fixed] Fixed a bug where settings updates weren't applied before fetches. (#4740)
36
- [changed] Updated public API documentation for 4.4.10 change from FirebaseInstanceID to
47
FirebaseInstallations. (#5561)
8+
59
# v4.4.10
610
- [changed] Internal code changes - migrate to using the FIS SDK. (#5096)
711
- [changed] Include both CFBundleString and CFBundleShortVersionString in the outgoing fetch requests.
12+
813
# v4.4.9
914
- [changed] Internal code changes. (#4934)
15+
1016
# v4.4.8
1117
- [fixed] Fixed a bug (#4677, #4734) where Remote Config does not work after a restore of a previous backup of the device. (#4896).
18+
1219
# v4.4.7
1320
- [fixed] Fixed a crash that could occur when attempting a remote config fetch before a valid Instance ID was available. (#4622)
1421
- [fixed] Fixed an issue where config fetch would sometimes fail with a duplicate fetch error when no other fetches were in progress. (#3802)

FirebaseRemoteConfig/Sources/FIRRemoteConfig.m

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -236,27 +236,28 @@ - (void)fetchAndActivateWithCompletionHandler:
236236
(FIRRemoteConfigFetchAndActivateCompletion)completionHandler {
237237
__weak FIRRemoteConfig *weakSelf = self;
238238
FIRRemoteConfigFetchCompletion fetchCompletion =
239-
^(FIRRemoteConfigFetchStatus fetchStatus, NSError *error) {
239+
^(FIRRemoteConfigFetchStatus fetchStatus, NSError *fetchError) {
240240
FIRRemoteConfig *strongSelf = weakSelf;
241241
if (!strongSelf) {
242242
return;
243243
}
244244
// Fetch completed. We are being called on the main queue.
245245
// If fetch is successful, try to activate the fetched config
246-
bool didActivate = false;
247-
if (fetchStatus == FIRRemoteConfigFetchStatusSuccess && !error) {
248-
didActivate = [strongSelf activateFetched];
249-
}
250-
if (completionHandler) {
251-
FIRRemoteConfigFetchAndActivateStatus status = FIRRemoteConfigFetchAndActivateStatusError;
252-
if (fetchStatus == FIRRemoteConfigFetchStatusSuccess) {
253-
status = didActivate ? FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote
254-
: FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData;
255-
} else {
256-
status = FIRRemoteConfigFetchAndActivateStatusError;
257-
}
258-
// Pass along the fetch error e.g. throttled.
259-
completionHandler(status, error);
246+
if (fetchStatus == FIRRemoteConfigFetchStatusSuccess && !fetchError) {
247+
[strongSelf activateWithCompletionHandler:^(NSError *_Nullable activateError) {
248+
if (completionHandler) {
249+
FIRRemoteConfigFetchAndActivateStatus status =
250+
activateError ? FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData
251+
: FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote;
252+
completionHandler(status, nil);
253+
}
254+
}];
255+
} else if (completionHandler) {
256+
FIRRemoteConfigFetchAndActivateStatus status =
257+
fetchStatus == FIRRemoteConfigFetchStatusSuccess
258+
? FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData
259+
: FIRRemoteConfigFetchAndActivateStatusError;
260+
completionHandler(status, fetchError);
260261
}
261262
};
262263
[self fetchWithCompletionHandler:fetchCompletion];

0 commit comments

Comments
 (0)