From 0a56cde2876ab3ea7e0c4f6933eaf5dc37267673 Mon Sep 17 00:00:00 2001 From: Gleb Volchetskiy Date: Thu, 20 Sep 2018 17:38:16 +0300 Subject: [PATCH] iOS fetch method error resolving added --- src/ios/FirebasePlugin.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ios/FirebasePlugin.m b/src/ios/FirebasePlugin.m index bd2c250f1..5103310b0 100644 --- a/src/ios/FirebasePlugin.m +++ b/src/ios/FirebasePlugin.m @@ -332,17 +332,23 @@ - (void)fetch:(CDVInvokedUrlCommand *)command { int expirationDuration = [[command.arguments objectAtIndex:0] intValue]; [remoteConfig fetchWithExpirationDuration:expirationDuration completionHandler:^(FIRRemoteConfigFetchStatus status, NSError * _Nullable error) { + CDVPluginResult *pluginResult; if (status == FIRRemoteConfigFetchStatusSuccess) { - CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + } else { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]; } + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; }]; } else { [remoteConfig fetchWithCompletionHandler:^(FIRRemoteConfigFetchStatus status, NSError * _Nullable error) { + CDVPluginResult *pluginResult; if (status == FIRRemoteConfigFetchStatusSuccess) { - CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + } else { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]; } + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; }]; } }];