From c2c01531f8dab3c77c5e9fc7f23c72a93cb34233 Mon Sep 17 00:00:00 2001 From: Chris Bianca Date: Thu, 17 Aug 2017 17:59:16 +0100 Subject: [PATCH] [ios] Remove erroneous check in --- ios/RNFirebase/config/RNFirebaseConfig.m | 136 ----------------------- 1 file changed, 136 deletions(-) delete mode 100644 ios/RNFirebase/config/RNFirebaseConfig.m diff --git a/ios/RNFirebase/config/RNFirebaseConfig.m b/ios/RNFirebase/config/RNFirebaseConfig.m deleted file mode 100644 index 0b3cf6e1..00000000 --- a/ios/RNFirebase/config/RNFirebaseConfig.m +++ /dev/null @@ -1,136 +0,0 @@ -#import "RNFirebaseRemoteConfig.h" - -#if __has_include() - -#import -#import -#import - -NSString *convertFIRRemoteConfigFetchStatusToNSString(FIRRemoteConfigFetchStatus value) { - switch (value) { - case FIRRemoteConfigFetchStatusNoFetchYet: - return @"config/no_fetch_yet"; - case FIRRemoteConfigFetchStatusSuccess: - return @"config/success"; - case FIRRemoteConfigFetchStatusThrottled: - return @"config/throttled"; - default: - return @"config/failure"; - } -} - -NSString *convertFIRRemoteConfigSourceToNSString(FIRRemoteConfigSource value) { - switch (value) { - case FIRRemoteConfigSourceDefault: - return @"default"; - case FIRRemoteConfigSourceRemote: - return @"remote"; - default: - return @"static"; - } -} - -NSDictionary *convertFIRRemoteConfigValueToNSDictionary(FIRRemoteConfigValue *value) { - return @{@"stringValue": value.stringValue ?: [NSNull null], @"numberValue": value.numberValue ?: [NSNull null], @"dataValue": value.dataValue ? [value.dataValue base64EncodedStringWithOptions:0] : [NSNull null], @"boolValue": @(value.boolValue), @"source": convertFIRRemoteConfigSourceToNSString(value.source)}; -} - -@implementation RNFirebaseRemoteConfig - -RCT_EXPORT_MODULE(RNFirebaseRemoteConfig); - -RCT_EXPORT_METHOD(enableDeveloperMode) { - FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:YES]; - [FIRRemoteConfig remoteConfig].configSettings = remoteConfigSettings; -} - -RCT_EXPORT_METHOD(fetch: - (RCTPromiseResolveBlock) resolve - rejecter: - (RCTPromiseRejectBlock) reject) { - [[FIRRemoteConfig remoteConfig] fetchWithCompletionHandler:^(FIRRemoteConfigFetchStatus status, NSError *__nullable error) { - if (error) { - RCTLogError(@"\nError: %@", RCTJSErrorFromNSError(error)); - reject(convertFIRRemoteConfigFetchStatusToNSString(status), error.localizedDescription, error); - } else { - resolve(convertFIRRemoteConfigFetchStatusToNSString(status)); - } - }]; -} - -RCT_EXPORT_METHOD(fetchWithExpirationDuration: - (nonnull - NSNumber *)expirationDuration - resolver:(RCTPromiseResolveBlock)resolve - rejecter:(RCTPromiseRejectBlock)reject) { - [[FIRRemoteConfig remoteConfig] fetchWithExpirationDuration:expirationDuration.doubleValue completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *__nullable error) { - if (error) { - RCTLogError(@"\nError: %@", RCTJSErrorFromNSError(error)); - reject(convertFIRRemoteConfigFetchStatusToNSString(status), error.localizedDescription, error); - } else { - resolve(convertFIRRemoteConfigFetchStatusToNSString(status)); - } - }]; -} - -RCT_EXPORT_METHOD(activateFetched: - (RCTPromiseResolveBlock) resolve - rejecter: - (RCTPromiseRejectBlock) reject) { - BOOL status = [[FIRRemoteConfig remoteConfig] activateFetched]; - resolve(@(status)); -} - -RCT_EXPORT_METHOD(getValue: - (NSString *) key - resolver: - (RCTPromiseResolveBlock) resolve - rejecter: - (RCTPromiseRejectBlock) reject) { - FIRRemoteConfigValue *value = [[FIRRemoteConfig remoteConfig] configValueForKey:key]; - resolve(convertFIRRemoteConfigValueToNSDictionary(value)); -} - -RCT_EXPORT_METHOD(getValues: - (NSArray *) keys - resolver: - (RCTPromiseResolveBlock) resolve - rejecter: - (RCTPromiseRejectBlock) reject) { - NSMutableArray *valuesArray = [[NSMutableArray alloc] init]; - for (NSString *key in keys) { - FIRRemoteConfigValue *value = [[FIRRemoteConfig remoteConfig] configValueForKey:key]; - [valuesArray addObject:convertFIRRemoteConfigValueToNSDictionary(value)]; - } - resolve(valuesArray); -} - -RCT_EXPORT_METHOD(getKeysByPrefix: - (NSString *) prefix - resolver: - (RCTPromiseResolveBlock) resolve - rejecter: - (RCTPromiseRejectBlock) reject) { - NSSet *keys = [[FIRRemoteConfig remoteConfig] keysWithPrefix:prefix]; - NSMutableArray *keysArray = [[NSMutableArray alloc] init]; - for (NSString *key in keys) { - [keysArray addObject:key]; - } - resolve(keysArray); -} - -RCT_EXPORT_METHOD(setDefaults: - (NSDictionary *) defaults) { - [[FIRRemoteConfig remoteConfig] setDefaults:defaults]; -} - -RCT_EXPORT_METHOD(setDefaultsFromResource: - (NSString *) fileName) { - [[FIRRemoteConfig remoteConfig] setDefaultsFromPlistFileName:fileName]; -} - -@end - -#else -@implementation RNFirebaseRemoteConfig -@end -#endif