mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-11 22:55:59 +05:45
Throw an error if the fetch response returns an error (irrespective o… (#4438)
* Throw an error if the fetch response returns an error (irrespective of status code). * Remove duplicate metadata set call. * Add comment.
This commit is contained in:
1 parent
374f1acd4f
commit
f47ce4bbf3
3 files changed
+174
-53
No files matched your search
@@ -159,39 +159,39 @@ static NSString *const FIRSecondFIRAppName = @"secondFIRApp";
|
||||
- (IBAction)fetchAndActivateButtonPressed:(id)sender {
|
||||
// fetchConfig api callback, this is triggered when client receives response from server
|
||||
ViewController *__weak weakSelf = self;
|
||||
FIRRemoteConfigFetchAndActivateCompletion fetchAndActivateCompletion =
|
||||
^(FIRRemoteConfigFetchAndActivateStatus status, NSError *error) {
|
||||
ViewController *strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
return;
|
||||
}
|
||||
NSMutableString *output = @"Fetch and activate status :";
|
||||
if (status == FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote) {
|
||||
[output appendString:@"Success from remote fetch."];
|
||||
} else if (status == FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData) {
|
||||
[output appendString:@"Success using pre-fetched data."];
|
||||
} else if (status == FIRRemoteConfigFetchAndActivateStatusError) {
|
||||
output appendString
|
||||
: [NSString stringWithFormat:@"Failure: %@", [error localizedDescription]];
|
||||
}
|
||||
FIRRemoteConfigFetchAndActivateCompletion fetchAndActivateCompletion = ^(
|
||||
FIRRemoteConfigFetchAndActivateStatus status, NSError *error) {
|
||||
ViewController *strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
return;
|
||||
}
|
||||
NSMutableString *output = [@"Fetch and activate status :" mutableCopy];
|
||||
if (status == FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote) {
|
||||
[output appendString:@"Success from remote fetch."];
|
||||
} else if (status == FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData) {
|
||||
[output appendString:@"Success using pre-fetched data."];
|
||||
} else if (status == FIRRemoteConfigFetchAndActivateStatusError) {
|
||||
[output
|
||||
appendString:[NSString stringWithFormat:@"Failure: %@", [error localizedDescription]]];
|
||||
}
|
||||
|
||||
if (error) {
|
||||
[output appendFormat:@"%@\n", error];
|
||||
}
|
||||
if (status == FIRRemoteConfigFetchAndActivateStatusError) {
|
||||
[output appendString:[NSString stringWithFormat:@"Fetch And Activate Error :%@.\n",
|
||||
[strongSelf errorString:error.code]]];
|
||||
if (error.code == FIRRemoteConfigErrorThrottled) {
|
||||
[output appendString:[NSString stringWithFormat:@"Throttled.\n"]];
|
||||
}
|
||||
}
|
||||
// activate status
|
||||
[[FRCLog sharedInstance] logToConsole:output];
|
||||
if (status == FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote ||
|
||||
status == FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData) {
|
||||
[strongSelf printResult:[[NSMutableString alloc] init]];
|
||||
}
|
||||
};
|
||||
if (error) {
|
||||
[output appendFormat:@"%@\n", error];
|
||||
}
|
||||
if (status == FIRRemoteConfigFetchAndActivateStatusError) {
|
||||
[output appendString:[NSString stringWithFormat:@"Fetch And Activate Error :%@.\n",
|
||||
[strongSelf errorString:error.code]]];
|
||||
if (error.code == FIRRemoteConfigErrorThrottled) {
|
||||
[output appendString:[NSString stringWithFormat:@"Throttled.\n"]];
|
||||
}
|
||||
}
|
||||
// activate status
|
||||
[[FRCLog sharedInstance] logToConsole:output];
|
||||
if (status == FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote ||
|
||||
status == FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData) {
|
||||
[strongSelf printResult:[[NSMutableString alloc] init]];
|
||||
}
|
||||
};
|
||||
|
||||
// fetchConfig api call
|
||||
[self.RCInstances[self.currentNamespace][self.FIRAppName]
|
||||
|
||||
Reference in new issue
Block a user