diff --git a/ios/RNFirebase/RNFirebase.h b/ios/RNFirebase/RNFirebase.h index aa6d128d..ea11a6eb 100644 --- a/ios/RNFirebase/RNFirebase.h +++ b/ios/RNFirebase/RNFirebase.h @@ -1,8 +1,6 @@ #ifndef RNFirebase_h #define RNFirebase_h -#import -#import #import #import diff --git a/ios/RNFirebase/RNFirebase.m b/ios/RNFirebase/RNFirebase.m index 1d7cfdf4..803a283c 100644 --- a/ios/RNFirebase/RNFirebase.m +++ b/ios/RNFirebase/RNFirebase.m @@ -1,36 +1,18 @@ #import "RNFirebase.h" -#import "RNFirebaseEvents.h" - -static dispatch_once_t onceToken; @implementation RNFirebase RCT_EXPORT_MODULE(RNFirebase); - -- (void)dealloc { - NSLog(@"Dealloc called on RNFirebase: %@", self); - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - - (id)init { self = [super init]; if (self != nil) { NSLog(@"Setting up RNFirebase instance"); - [RNFirebase initializeRNFirebase]; } return self; } -+ (void)initializeRNFirebase { -#if __has_include() - dispatch_once(&onceToken, ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:kRNFirebaseInitialized object:nil]; - }); -#endif -} - - (NSArray *)supportedEvents { - return @[INITIALIZED_EVENT]; + return @[]; } -@end \ No newline at end of file +@end diff --git a/ios/RNFirebase/RNFirebaseAnalytics.m b/ios/RNFirebase/RNFirebaseAnalytics.m index 6a9ac1c4..24f0a043 100644 --- a/ios/RNFirebase/RNFirebaseAnalytics.m +++ b/ios/RNFirebase/RNFirebaseAnalytics.m @@ -1,4 +1,3 @@ -#import "RNFirebase.h" #import "RNFirebaseAnalytics.h" #if __has_include() diff --git a/ios/RNFirebase/RNFirebaseDatabase.h b/ios/RNFirebase/RNFirebaseDatabase.h index d889e55e..291c40ef 100644 --- a/ios/RNFirebase/RNFirebaseDatabase.h +++ b/ios/RNFirebase/RNFirebaseDatabase.h @@ -5,7 +5,6 @@ #import #if __has_include() -#import "Firebase.h" @interface RNFirebaseDatabase : RCTEventEmitter {} @property NSMutableDictionary *dbReferences; diff --git a/ios/RNFirebase/RNFirebaseDatabase.m b/ios/RNFirebase/RNFirebaseDatabase.m index e302a310..c8efcd83 100644 --- a/ios/RNFirebase/RNFirebaseDatabase.m +++ b/ios/RNFirebase/RNFirebaseDatabase.m @@ -1,7 +1,6 @@ -#import "RNFirebase.h" #import "RNFirebaseDatabase.h" #import "RNFirebaseEvents.h" - +#import "Firebase.h" #if __has_include() diff --git a/ios/RNFirebase/RNFirebaseEvents.h b/ios/RNFirebase/RNFirebaseEvents.h index b344c786..567f5cac 100644 --- a/ios/RNFirebase/RNFirebaseEvents.h +++ b/ios/RNFirebase/RNFirebaseEvents.h @@ -3,20 +3,9 @@ #import -#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) -#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) -#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) -#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) -#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) -#define RNFIREBASE_QUEUE_NAME "com.invertase.firebase.WorkerQueue" - -static NSString *const kRNFirebaseInitialized = @"RNFirebaseInitializedEvent"; -static NSString *const INITIALIZED_EVENT = @"RNFirebaseInitialized"; - static NSString *const AUTH_CHANGED_EVENT = @"onAuthStateChanged"; static NSString *const AUTH_ERROR_EVENT = @"authError"; static NSString *const AUTH_ANONYMOUS_ERROR_EVENT = @"authAnonymousError"; -static NSString *const DEBUG_EVENT = @"debug"; // Database static NSString *const DATABASE_DATA_EVENT = @"database_event"; @@ -29,7 +18,6 @@ static NSString *const DATABASE_CHILD_MODIFIED_EVENT = @"child_changed"; static NSString *const DATABASE_CHILD_REMOVED_EVENT = @"child_removed"; static NSString *const DATABASE_CHILD_MOVED_EVENT = @"child_moved"; - // Storage static NSString *const STORAGE_EVENT = @"storage_event"; static NSString *const STORAGE_ERROR = @"storage_error"; diff --git a/ios/RNFirebase/RNFirebaseMessaging.h b/ios/RNFirebase/RNFirebaseMessaging.h index 66f16ea8..93e512ec 100644 --- a/ios/RNFirebase/RNFirebaseMessaging.h +++ b/ios/RNFirebase/RNFirebaseMessaging.h @@ -5,12 +5,8 @@ #import #if __has_include() -#import "Firebase.h" #import -#import -#import - @import UserNotifications; @interface RNFirebaseMessaging : RCTEventEmitter diff --git a/ios/RNFirebase/RNFirebaseMessaging.m b/ios/RNFirebase/RNFirebaseMessaging.m index 4572633f..8ec75e8d 100644 --- a/ios/RNFirebase/RNFirebaseMessaging.m +++ b/ios/RNFirebase/RNFirebaseMessaging.m @@ -1,14 +1,14 @@ #import "RNFirebaseMessaging.h" + +@import UserNotifications; +#if __has_include() #import "RNFirebaseEvents.h" +#import #import #import #import -@import UserNotifications; -#if __has_include() -#import - @implementation RCTConvert (NSCalendarUnit) RCT_ENUM_CONVERTER(NSCalendarUnit, diff --git a/ios/RNFirebase/RNFirebaseRemoteConfig.m b/ios/RNFirebase/RNFirebaseRemoteConfig.m index f938290e..6bf67138 100644 --- a/ios/RNFirebase/RNFirebaseRemoteConfig.m +++ b/ios/RNFirebase/RNFirebaseRemoteConfig.m @@ -1,9 +1,8 @@ #import "RNFirebaseRemoteConfig.h" -#import - #if __has_include() #import "FirebaseRemoteConfig/FirebaseRemoteConfig.h" +#import NSString *convertFIRRemoteConfigFetchStatusToNSString(FIRRemoteConfigFetchStatus value) { @@ -52,21 +51,13 @@ NSDictionary *convertFIRRemoteConfigValueToNSDictionary(FIRRemoteConfigValue *va RCT_EXPORT_MODULE(RNFirebaseRemoteConfig); -- (id)init -{ - if (self = [super init]) { - _remoteConfig = [FIRRemoteConfig remoteConfig]; - } - return self; -} - RCT_EXPORT_METHOD(enableDeveloperMode) { FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:YES]; - self.remoteConfig.configSettings = remoteConfigSettings; + [FIRRemoteConfig remoteConfig].configSettings = remoteConfigSettings; } RCT_EXPORT_METHOD(fetch:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { - [self.remoteConfig fetchWithCompletionHandler:^(FIRRemoteConfigFetchStatus status, NSError *__nullable error) { + [[FIRRemoteConfig remoteConfig] fetchWithCompletionHandler:^(FIRRemoteConfigFetchStatus status, NSError *__nullable error) { if (error) { RCTLogError(@"\nError: %@", RCTJSErrorFromNSError(error)); reject(convertFIRRemoteConfigFetchStatusToNSString(status), error.localizedDescription, error); @@ -80,7 +71,7 @@ RCT_EXPORT_METHOD(fetchWithExpirationDuration:(nonnull NSNumber *)expirationDura resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { - [self.remoteConfig fetchWithExpirationDuration:expirationDuration.doubleValue completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *__nullable error) { + [[FIRRemoteConfig remoteConfig] fetchWithExpirationDuration:expirationDuration.doubleValue completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *__nullable error) { if (error) { RCTLogError(@"\nError: %@", RCTJSErrorFromNSError(error)); reject(convertFIRRemoteConfigFetchStatusToNSString(status), error.localizedDescription, error); @@ -93,7 +84,7 @@ RCT_EXPORT_METHOD(fetchWithExpirationDuration:(nonnull NSNumber *)expirationDura RCT_EXPORT_METHOD(activateFetched:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { - BOOL status = [self.remoteConfig activateFetched]; + BOOL status = [[FIRRemoteConfig remoteConfig] activateFetched]; resolve(@(status)); } @@ -101,7 +92,7 @@ RCT_EXPORT_METHOD(getValue:(NSString *)key resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { - FIRRemoteConfigValue *value = [self.remoteConfig configValueForKey:key]; + FIRRemoteConfigValue *value = [[FIRRemoteConfig remoteConfig] configValueForKey:key]; resolve(convertFIRRemoteConfigValueToNSDictionary(value)); } @@ -111,7 +102,7 @@ RCT_EXPORT_METHOD(getValues:(NSArray *)keys { NSMutableArray *valuesArray = [[NSMutableArray alloc] init]; for (NSString *key in keys) { - FIRRemoteConfigValue *value = [self.remoteConfig configValueForKey:key]; + FIRRemoteConfigValue *value = [[FIRRemoteConfig remoteConfig] configValueForKey:key]; [valuesArray addObject:convertFIRRemoteConfigValueToNSDictionary(value)]; } resolve(valuesArray); @@ -121,7 +112,7 @@ RCT_EXPORT_METHOD(getKeysByPrefix:(NSString *)prefix resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { - NSSet *keys = [self.remoteConfig keysWithPrefix:prefix]; + NSSet *keys = [[FIRRemoteConfig remoteConfig] keysWithPrefix:prefix]; NSMutableArray *keysArray = [[NSMutableArray alloc] init]; for (NSString *key in keys) { [keysArray addObject:key]; @@ -130,11 +121,11 @@ RCT_EXPORT_METHOD(getKeysByPrefix:(NSString *)prefix } RCT_EXPORT_METHOD(setDefaults:(NSDictionary *)defaults) { - [self.remoteConfig setDefaults:defaults]; + [[FIRRemoteConfig remoteConfig] setDefaults:defaults]; } RCT_EXPORT_METHOD(setDefaultsFromResource:(NSString *)fileName) { - [self.remoteConfig setDefaultsFromPlistFileName:fileName]; + [[FIRRemoteConfig remoteConfig] setDefaultsFromPlistFileName:fileName]; } @end @@ -144,4 +135,4 @@ RCT_EXPORT_METHOD(setDefaultsFromResource:(NSString *)fileName) { RCT_EXPORT_MODULE(); RCT_EXPORT_METHOD(nativeSDKMissing) {} @end -#endif \ No newline at end of file +#endif