2022-08-08 21:02:08 +00:00
|
|
|
#import "AppDelegate.h"
|
|
|
|
#import <React/RCTBridge.h>
|
|
|
|
#import <React/RCTBundleURLProvider.h>
|
|
|
|
#import <React/RCTRootView.h>
|
|
|
|
#import <React/RCTLinkingManager.h>
|
|
|
|
#import "RNNotifications.h"
|
|
|
|
#import "RNBootSplash.h"
|
|
|
|
#import "Orientation.h"
|
|
|
|
#import <Firebase.h>
|
|
|
|
#import <Bugsnag/Bugsnag.h>
|
|
|
|
#import <MMKV/MMKV.h>
|
|
|
|
|
|
|
|
#import <React/RCTAppSetupUtils.h>
|
|
|
|
#if RCT_NEW_ARCH_ENABLED
|
|
|
|
#import <React/CoreModulesPlugins.h>
|
|
|
|
#import <React/RCTCxxBridgeDelegate.h>
|
|
|
|
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
|
|
|
|
#import <React/RCTSurfacePresenter.h>
|
|
|
|
#import <React/RCTSurfacePresenterBridgeAdapter.h>
|
|
|
|
#import <ReactCommon/RCTTurboModuleManager.h>
|
|
|
|
#import <react/config/ReactNativeConfig.h>
|
|
|
|
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
|
|
|
|
RCTTurboModuleManager *_turboModuleManager;
|
|
|
|
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
|
|
|
|
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
|
|
|
|
facebook::react::ContextContainer::Shared _contextContainer;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
#endif
|
|
|
|
|
|
|
|
@implementation AppDelegate
|
|
|
|
|
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
|
|
{
|
|
|
|
RCTAppSetupPrepareApp(application);
|
|
|
|
RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions];
|
|
|
|
#if RCT_NEW_ARCH_ENABLED
|
|
|
|
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();
|
|
|
|
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
|
|
|
|
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
|
|
|
|
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
|
|
|
|
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
|
|
|
|
#endif
|
|
|
|
if(![FIRApp defaultApp]){
|
|
|
|
[FIRApp configure];
|
|
|
|
}
|
|
|
|
[Bugsnag start];
|
|
|
|
|
|
|
|
UIView *rootView = [self.reactDelegate createRootViewWithBridge:bridge moduleName:@"RocketChatRN" initialProperties:nil];
|
|
|
|
|
|
|
|
if (@available(iOS 13.0, *)) {
|
|
|
|
rootView.backgroundColor = [UIColor systemBackgroundColor];
|
|
|
|
} else {
|
|
|
|
rootView.backgroundColor = [UIColor whiteColor];
|
|
|
|
}
|
|
|
|
|
|
|
|
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
2023-01-20 16:55:53 +00:00
|
|
|
UIViewController *rootViewController = [UIViewController new];
|
|
|
|
UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:rootViewController];
|
|
|
|
navigationController.navigationBarHidden = YES;
|
2022-08-08 21:02:08 +00:00
|
|
|
rootViewController.view = rootView;
|
2023-01-20 16:55:53 +00:00
|
|
|
self.window.rootViewController = navigationController;
|
2022-08-08 21:02:08 +00:00
|
|
|
[self.window makeKeyAndVisible];
|
2022-09-23 20:35:03 +00:00
|
|
|
[RNNotifications startMonitorNotifications];
|
|
|
|
[ReplyNotification configure];
|
|
|
|
|
2022-08-08 21:02:08 +00:00
|
|
|
// AppGroup MMKV
|
|
|
|
NSString *groupDir = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppGroup"]].path;
|
2023-01-18 16:43:26 +00:00
|
|
|
[MMKV initializeMMKV:nil groupDir:groupDir logLevel:MMKVLogInfo];
|
2022-08-08 21:02:08 +00:00
|
|
|
|
|
|
|
[RNBootSplash initWithStoryboard:@"LaunchScreen" rootView:rootView];
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
|
|
|
|
{
|
|
|
|
#if DEBUG
|
|
|
|
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
|
|
|
|
#else
|
|
|
|
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#if RCT_NEW_ARCH_ENABLED
|
|
|
|
#pragma mark - RCTCxxBridgeDelegate
|
|
|
|
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
|
|
|
|
{
|
|
|
|
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
|
|
|
|
delegate:self
|
|
|
|
jsInvoker:bridge.jsCallInvoker];
|
|
|
|
return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
|
|
|
|
}
|
|
|
|
#pragma mark RCTTurboModuleManagerDelegate
|
|
|
|
- (Class)getModuleClassFromName:(const char *)name
|
|
|
|
{
|
|
|
|
return RCTCoreModulesClassProvider(name);
|
|
|
|
}
|
|
|
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
|
|
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
|
|
initParams:
|
|
|
|
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
|
|
|
|
{
|
|
|
|
return RCTAppSetupDefaultModuleFromClass(moduleClass);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
|
|
|
{
|
|
|
|
[RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
|
|
|
|
[RNNotifications didFailToRegisterForRemoteNotificationsWithError:error];
|
|
|
|
}
|
|
|
|
|
2022-08-11 19:40:31 +00:00
|
|
|
- (BOOL)application:(UIApplication *)application
|
|
|
|
openURL:(NSURL *)url
|
|
|
|
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
|
2022-08-08 21:02:08 +00:00
|
|
|
{
|
2022-08-11 19:40:31 +00:00
|
|
|
return [RCTLinkingManager application:application openURL:url options:options];
|
2022-08-08 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
2022-08-11 19:40:31 +00:00
|
|
|
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
|
|
|
|
restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
|
2022-08-08 21:02:08 +00:00
|
|
|
{
|
2022-08-11 19:40:31 +00:00
|
|
|
return [RCTLinkingManager application:application
|
|
|
|
continueUserActivity:userActivity
|
|
|
|
restorationHandler:restorationHandler];
|
2022-08-08 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
2022-08-11 19:40:31 +00:00
|
|
|
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
|
2022-08-08 21:02:08 +00:00
|
|
|
{
|
2022-08-11 19:40:31 +00:00
|
|
|
return [Orientation getOrientation];
|
2022-08-08 21:02:08 +00:00
|
|
|
}
|
|
|
|
@end
|