-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Migrate FetchAndActivate from deprecated implementation #5617
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,27 +236,28 @@ - (void)fetchAndActivateWithCompletionHandler: | |
| (FIRRemoteConfigFetchAndActivateCompletion)completionHandler { | ||
| __weak FIRRemoteConfig *weakSelf = self; | ||
| FIRRemoteConfigFetchCompletion fetchCompletion = | ||
| ^(FIRRemoteConfigFetchStatus fetchStatus, NSError *error) { | ||
| ^(FIRRemoteConfigFetchStatus fetchStatus, NSError *fetchError) { | ||
| FIRRemoteConfig *strongSelf = weakSelf; | ||
| if (!strongSelf) { | ||
| return; | ||
| } | ||
| // Fetch completed. We are being called on the main queue. | ||
| // If fetch is successful, try to activate the fetched config | ||
| bool didActivate = false; | ||
| if (fetchStatus == FIRRemoteConfigFetchStatusSuccess && !error) { | ||
| didActivate = [strongSelf activateFetched]; | ||
| } | ||
| if (completionHandler) { | ||
| FIRRemoteConfigFetchAndActivateStatus status = FIRRemoteConfigFetchAndActivateStatusError; | ||
| if (fetchStatus == FIRRemoteConfigFetchStatusSuccess) { | ||
| status = didActivate ? FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote | ||
| : FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData; | ||
| } else { | ||
| status = FIRRemoteConfigFetchAndActivateStatusError; | ||
| } | ||
| // Pass along the fetch error e.g. throttled. | ||
| completionHandler(status, error); | ||
| if (fetchStatus == FIRRemoteConfigFetchStatusSuccess && !fetchError) { | ||
| [strongSelf activateWithCompletionHandler:^(NSError *_Nullable activateError) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! it's odd that it was using sync method even tho this async method exists. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| if (completionHandler) { | ||
| FIRRemoteConfigFetchAndActivateStatus status = | ||
| activateError ? FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData | ||
| : FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote; | ||
| completionHandler(status, nil); | ||
| } | ||
| }]; | ||
| } else if (completionHandler) { | ||
| FIRRemoteConfigFetchAndActivateStatus status = | ||
| fetchStatus == FIRRemoteConfigFetchStatusSuccess | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it possible that the fetchStatus is successful and fetchError also exists? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes - if the config didn't change. See #3586. I'm planning to deprecate that API and add a new API that returns a bool like Android and JS instead of an error - after I get some integration test infra set up. |
||
| ? FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData | ||
| : FIRRemoteConfigFetchAndActivateStatusError; | ||
| completionHandler(status, fetchError); | ||
| } | ||
| }; | ||
| [self fetchWithCompletionHandler:fetchCompletion]; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is a great candidate to be refactored with Promises. We can consider it for future PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! This and several other RC methods.