[ios] Tidy up of iOS imports and other misc clean up
This commit is contained in:
parent
6c04c8484a
commit
dcd6321561
|
@ -1,8 +1,6 @@
|
|||
#ifndef RNFirebase_h
|
||||
#define RNFirebase_h
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <React/RCTEventDispatcher.h>
|
||||
#import <React/RCTEventEmitter.h>
|
||||
#import <React/RCTBridgeModule.h>
|
||||
|
||||
|
|
|
@ -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(<FirebaseMessaging/FirebaseMessaging.h>)
|
||||
dispatch_once(&onceToken, ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kRNFirebaseInitialized object:nil];
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)supportedEvents {
|
||||
return @[INITIALIZED_EVENT];
|
||||
return @[];
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#import "RNFirebase.h"
|
||||
#import "RNFirebaseAnalytics.h"
|
||||
|
||||
#if __has_include(<FirebaseAnalytics/FIRAnalytics.h>)
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#import <React/RCTBridgeModule.h>
|
||||
|
||||
#if __has_include(<FirebaseDatabase/FIRDatabase.h>)
|
||||
#import "Firebase.h"
|
||||
|
||||
@interface RNFirebaseDatabase : RCTEventEmitter <RCTBridgeModule> {}
|
||||
@property NSMutableDictionary *dbReferences;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#import "RNFirebase.h"
|
||||
#import "RNFirebaseDatabase.h"
|
||||
#import "RNFirebaseEvents.h"
|
||||
|
||||
#import "Firebase.h"
|
||||
|
||||
#if __has_include(<FirebaseDatabase/FIRDatabase.h>)
|
||||
|
||||
|
|
|
@ -3,20 +3,9 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#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";
|
||||
|
|
|
@ -5,12 +5,8 @@
|
|||
#import <React/RCTBridgeModule.h>
|
||||
|
||||
#if __has_include(<FirebaseMessaging/FirebaseMessaging.h>)
|
||||
#import "Firebase.h"
|
||||
#import <FirebaseMessaging/FirebaseMessaging.h>
|
||||
|
||||
#import <React/RCTUtils.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@import UserNotifications;
|
||||
|
||||
@interface RNFirebaseMessaging : RCTEventEmitter<RCTBridgeModule, FIRMessagingDelegate>
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#import "RNFirebaseMessaging.h"
|
||||
|
||||
@import UserNotifications;
|
||||
#if __has_include(<FirebaseMessaging/FirebaseMessaging.h>)
|
||||
#import "RNFirebaseEvents.h"
|
||||
#import <FirebaseMessaging/FirebaseMessaging.h>
|
||||
|
||||
#import <React/RCTEventDispatcher.h>
|
||||
#import <React/RCTConvert.h>
|
||||
#import <React/RCTUtils.h>
|
||||
|
||||
@import UserNotifications;
|
||||
#if __has_include(<FirebaseMessaging/FirebaseMessaging.h>)
|
||||
#import <FirebaseMessaging/FirebaseMessaging.h>
|
||||
|
||||
@implementation RCTConvert (NSCalendarUnit)
|
||||
|
||||
RCT_ENUM_CONVERTER(NSCalendarUnit,
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#import "RNFirebaseRemoteConfig.h"
|
||||
|
||||
#import <React/RCTConvert.h>
|
||||
|
||||
#if __has_include(<FirebaseRemoteConfig/FirebaseRemoteConfig.h>)
|
||||
#import "FirebaseRemoteConfig/FirebaseRemoteConfig.h"
|
||||
#import <React/RCTConvert.h>
|
||||
|
||||
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
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue