[config][ios] Match iOS error messages to Android

This commit is contained in:
Elliot Hesp 2018-07-12 14:14:11 +01:00
parent fc39b35e1a
commit c4b43a5184
1 changed files with 12 additions and 2 deletions

View File

@ -19,6 +19,16 @@ NSString *convertFIRRemoteConfigFetchStatusToNSString(FIRRemoteConfigFetchStatus
}
}
NSString *convertFIRRemoteConfigFetchStatusToNSStringDescription(FIRRemoteConfigFetchStatus value) {
switch (value) {
case FIRRemoteConfigFetchStatusThrottled:
return @"fetch() operation cannot be completed successfully, due to throttling.";
case FIRRemoteConfigFetchStatusNoFetchYet:
default:
return @"fetch() operation cannot be completed successfully.";
}
}
NSString *convertFIRRemoteConfigSourceToNSString(FIRRemoteConfigSource value) {
switch (value) {
case FIRRemoteConfigSourceDefault:
@ -49,7 +59,7 @@ RCT_EXPORT_METHOD(fetch:
(RCTPromiseRejectBlock) reject) {
[[FIRRemoteConfig remoteConfig] fetchWithCompletionHandler:^(FIRRemoteConfigFetchStatus status, NSError *__nullable error) {
if (error) {
reject(convertFIRRemoteConfigFetchStatusToNSString(status), error.localizedDescription, error);
reject(convertFIRRemoteConfigFetchStatusToNSString(status), convertFIRRemoteConfigFetchStatusToNSStringDescription(status), error);
} else {
resolve(convertFIRRemoteConfigFetchStatusToNSString(status));
}
@ -63,7 +73,7 @@ RCT_EXPORT_METHOD(fetchWithExpirationDuration:
rejecter:(RCTPromiseRejectBlock)reject) {
[[FIRRemoteConfig remoteConfig] fetchWithExpirationDuration:expirationDuration.doubleValue completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *__nullable error) {
if (error) {
reject(convertFIRRemoteConfigFetchStatusToNSString(status), error.localizedDescription, error);
reject(convertFIRRemoteConfigFetchStatusToNSString(status), convertFIRRemoteConfigFetchStatusToNSStringDescription(status), error);
} else {
resolve(convertFIRRemoteConfigFetchStatusToNSString(status));
}