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 @@ -17,8 +17,10 @@ #import "CommCoreModule.h" #import "GlobalNetworkSingleton.h" #import "Logger.h" +#import "MessageOperationsUtilities.h" #import "NetworkModule.h" #import "SQLiteQueryExecutor.h" +#import "TemporalMessageStorage.h" #import "ThreadOperations.h" #import "Tools.h" #import @@ -75,7 +77,7 @@ #ifdef FB_SONARKIT_ENABLED InitializeFlipper(application); #endif - + [self moveMessagesToDatabase]; RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge @@ -261,6 +263,16 @@ comm::SQLiteQueryExecutor::initialize(sqliteFilePath); } +- (void)moveMessagesToDatabase { + TemporalMessageStorage *temporalStorage = + [[TemporalMessageStorage alloc] init]; + NSArray *messages = [temporalStorage readAndClearMessages]; + for (NSString *message in messages) { + std::string messageInfos = std::string([message UTF8String]); + comm::MessageOperationsUtilities::storeMessageInfos(messageInfos); + } +} + // Copied from // ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp static ::hermes::vm::RuntimeConfig