Changeset View
Changeset View
Standalone View
Standalone View
native/ios/Comm/AppDelegate.mm
Show All 34 Lines | |||||
#import <React/RCTJSIExecutorRuntimeInstaller.h> | #import <React/RCTJSIExecutorRuntimeInstaller.h> | ||||
#import <React/RCTLinkingManager.h> | #import <React/RCTLinkingManager.h> | ||||
#import <cxxreact/JSExecutor.h> | #import <cxxreact/JSExecutor.h> | ||||
#import <jsireact/JSIExecutor.h> | #import <jsireact/JSIExecutor.h> | ||||
#import <reacthermes/HermesExecutorFactory.h> | #import <reacthermes/HermesExecutorFactory.h> | ||||
#import "CommConstants.h" | #import "CommConstants.h" | ||||
#import "CommCoreModule.h" | #import "CommCoreModule.h" | ||||
#import "CommIOSBlobClient.h" | |||||
#import "CommMMKV.h" | #import "CommMMKV.h" | ||||
#import "CommRustModule.h" | #import "CommRustModule.h" | ||||
#import "CommUtilsModule.h" | #import "CommUtilsModule.h" | ||||
#import "GlobalDBSingleton.h" | #import "GlobalDBSingleton.h" | ||||
#import "Logger.h" | #import "Logger.h" | ||||
#import "MessageOperationsUtilities.h" | #import "MessageOperationsUtilities.h" | ||||
#import "TemporaryMessageStorage.h" | #import "TemporaryMessageStorage.h" | ||||
#import "ThreadOperations.h" | #import "ThreadOperations.h" | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | - (BOOL)application:(UIApplication *)application | ||||
return YES; | return YES; | ||||
} | } | ||||
- (BOOL)application:(UIApplication *)application | - (BOOL)application:(UIApplication *)application | ||||
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||||
RCTAppSetupPrepareApp(application); | RCTAppSetupPrepareApp(application); | ||||
[self moveMessagesToDatabase:NO]; | [self moveMessagesToDatabase:NO]; | ||||
[self scheduleNSEBlobsDeletion]; | |||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient | [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient | ||||
error:nil]; | error:nil]; | ||||
RCTBridge *bridge = | RCTBridge *bridge = | ||||
[self.reactDelegate createBridgeWithDelegate:self | [self.reactDelegate createBridgeWithDelegate:self | ||||
launchOptions:launchOptions]; | launchOptions:launchOptions]; | ||||
#if RCT_NEW_ARCH_ENABLED | #if RCT_NEW_ARCH_ENABLED | ||||
▲ Show 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | for (NSString *rescindMessage in rescindMessages) { | ||||
comm::GlobalDBSingleton::instance.scheduleOrRun([threadID]() mutable { | comm::GlobalDBSingleton::instance.scheduleOrRun([threadID]() mutable { | ||||
comm::ThreadOperations::updateSQLiteUnreadStatus(threadID, false); | comm::ThreadOperations::updateSQLiteUnreadStatus(threadID, false); | ||||
}); | }); | ||||
} | } | ||||
} | } | ||||
- (void)didReceiveNewMessageInfosNSNotification:(NSNotification *)notification { | - (void)didReceiveNewMessageInfosNSNotification:(NSNotification *)notification { | ||||
[self moveMessagesToDatabase:YES]; | [self moveMessagesToDatabase:YES]; | ||||
[self scheduleNSEBlobsDeletion]; | |||||
} | } | ||||
- (void)registerForNewMessageInfosNotifications { | - (void)registerForNewMessageInfosNotifications { | ||||
[[NSNotificationCenter defaultCenter] | [[NSNotificationCenter defaultCenter] | ||||
addObserver:self | addObserver:self | ||||
selector:@selector(didReceiveNewMessageInfosNSNotification:) | selector:@selector(didReceiveNewMessageInfosNSNotification:) | ||||
name:newMessageInfosNSNotification | name:newMessageInfosNSNotification | ||||
object:nil]; | object:nil]; | ||||
CFNotificationCenterAddObserver( | CFNotificationCenterAddObserver( | ||||
CFNotificationCenterGetDarwinNotifyCenter(), | CFNotificationCenterGetDarwinNotifyCenter(), | ||||
(__bridge const void *)(self), | (__bridge const void *)(self), | ||||
didReceiveNewMessageInfosDarwinNotification, | didReceiveNewMessageInfosDarwinNotification, | ||||
newMessageInfosDarwinNotification, | newMessageInfosDarwinNotification, | ||||
NULL, | NULL, | ||||
CFNotificationSuspensionBehaviorDeliverImmediately); | CFNotificationSuspensionBehaviorDeliverImmediately); | ||||
} | } | ||||
// NSE has limited time to process notifications. Therefore | |||||
// deferable and low priority networking such as fetched | |||||
// blob deletion from blob service should be handled by the | |||||
// main app on a low priority background thread. | |||||
- (void)scheduleNSEBlobsDeletion { | |||||
dispatch_async( | |||||
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ | |||||
[CommIOSBlobClient.sharedInstance deleteStoredBlobs]; | |||||
}); | |||||
} | |||||
- (void)applicationWillResignActive:(UIApplication *)application { | |||||
[[CommIOSBlobClient sharedInstance] cancelOngoingRequests]; | |||||
} | |||||
// Copied from | // Copied from | ||||
// ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp | // ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp | ||||
static ::hermes::vm::RuntimeConfig | static ::hermes::vm::RuntimeConfig | ||||
makeRuntimeConfig(::hermes::vm::gcheapsize_t heapSizeMB) { | makeRuntimeConfig(::hermes::vm::gcheapsize_t heapSizeMB) { | ||||
namespace vm = ::hermes::vm; | namespace vm = ::hermes::vm; | ||||
auto gcConfigBuilder = | auto gcConfigBuilder = | ||||
vm::GCConfig::Builder() | vm::GCConfig::Builder() | ||||
.withName("RN") | .withName("RN") | ||||
Show All 23 Lines |