diff --git a/native/ios/Comm/AppDelegate.mm b/native/ios/Comm/AppDelegate.mm --- a/native/ios/Comm/AppDelegate.mm +++ b/native/ios/Comm/AppDelegate.mm @@ -7,7 +7,6 @@ #import #import -#import #import #import #import @@ -15,11 +14,7 @@ #import #import -#import - #import "CommCoreModule.h" -#import "CommSecureStore.h" -#import "CommSecureStoreIOSWrapper.h" #import "GlobalNetworkSingleton.h" #import "NetworkModule.h" #import "SQLiteQueryExecutor.h" @@ -62,12 +57,14 @@ } @end -@interface CommSecureStoreIOSWrapper () -- (void)init:(EXSecureStore *)secureStore; -@end - @implementation AppDelegate +- (BOOL)application:(UIApplication *)application + willFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [self attemptDatabaseInitialization]; + return YES; +} + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { #ifdef FB_SONARKIT_ENABLED @@ -103,17 +100,6 @@ rootView.loadingViewFadeDelay = 0; rootView.loadingViewFadeDuration = 0.001; - EXModuleRegistryProvider *moduleRegistryProvider = - [[EXModuleRegistryProvider alloc] init]; - EXSecureStore *secureStore = - (EXSecureStore *)[[moduleRegistryProvider moduleRegistry] - getExportedModuleOfClass:EXSecureStore.class]; - [[CommSecureStoreIOSWrapper sharedInstance] init:secureStore]; - - // initialize SQLiteQueryExecutor - std::string sqliteFilePath = - std::string([[Tools getSQLiteFilePath] UTF8String]); - comm::SQLiteQueryExecutor::initialize(sqliteFilePath); return YES; } @@ -243,6 +229,12 @@ makeRuntimeConfig(3072)); } +- (void)attemptDatabaseInitialization { + std::string sqliteFilePath = + std::string([[Tools getSQLiteFilePath] UTF8String]); + comm::SQLiteQueryExecutor::initialize(sqliteFilePath); +} + // Copied from // ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp static ::hermes::vm::RuntimeConfig diff --git a/native/ios/Comm/CommSecureStoreIOSWrapper.mm b/native/ios/Comm/CommSecureStoreIOSWrapper.mm --- a/native/ios/Comm/CommSecureStoreIOSWrapper.mm +++ b/native/ios/Comm/CommSecureStoreIOSWrapper.mm @@ -1,9 +1,10 @@ #import "CommSecureStoreIOSWrapper.h" #import "CommSecureStoreIOSWrapper.h" +#import @interface CommSecureStoreIOSWrapper () -@property(nonatomic, assign) EXSecureStore *secureStore; +@property(nonatomic, strong) EXSecureStore *secureStore; @property(nonatomic, strong) NSDictionary *options; @end @@ -26,14 +27,16 @@ static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ shared = [[self alloc] init]; + EXModuleRegistryProvider *moduleRegistryProvider = + [[EXModuleRegistryProvider alloc] init]; + EXSecureStore *secureStore = + (EXSecureStore *)[[moduleRegistryProvider moduleRegistry] + getExportedModuleOfClass:EXSecureStore.class]; + shared.secureStore = secureStore; }); return shared; } -- (void)init:(EXSecureStore *)secureStore { - _secureStore = secureStore; -} - - (void)set:(NSString *)key value:(NSString *)value { if ([self secureStore] == nil) { [NSException raise:@"secure store error"