-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathAppDelegate.m
More file actions
78 lines (64 loc) · 3.22 KB
/
Copy pathAppDelegate.m
File metadata and controls
78 lines (64 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#import "AppDelegate.h"
#import "MendixAppDelegate.h"
#import <MendixNative.h>
#import "IQKeyboardManager/IQKeyboardManager.h"
#import "SplashScreenPresenter.h"
@implementation AppDelegate
@synthesize shouldOpenInLastApp;
@synthesize hasHandledLaunchAppWithOptions;
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self clearKeychain];
[MendixAppDelegate application:application didFinishLaunchingWithOptions:launchOptions];
[self setupUI];
IQKeyboardManager.sharedManager.enable = NO;
self.window = [[MendixReactWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"LaunchApp" bundle:nil];
self.window.rootViewController = [storyboard instantiateInitialViewController];
[self.window makeKeyAndVisible];
[self.window setUserInteractionEnabled:YES];
return YES;
}
- (BOOL) application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
BOOL isHandled = [MendixAppDelegate application:application openURL:url options:options];
NSString *appUrl = [AppPreferences getAppUrl];
if (!isHandled || appUrl == nil || [appUrl length] == 0 || [ReactNative.instance isActive]) {
return NO;
}
NSURL *bundleUrl = [AppUrl forBundle:appUrl port:[AppPreferences getRemoteDebuggingPackagerPort] isDebuggingRemotely:[AppPreferences remoteDebuggingEnabled] isDevModeEnabled:[AppPreferences devModeEnabled]];
NSURL *runtimeUrl = [AppUrl forRuntime:appUrl];
NSMutableDictionary *launchOptions = [options mutableCopy];
[launchOptions setValue:[options valueForKey:UIApplicationOpenURLOptionsAnnotationKey] forKey:UIApplicationOpenURLOptionsAnnotationKey];
[launchOptions setValue:url forKey:UIApplicationLaunchOptionsURLKey];
MendixApp *mendixApp = [[MendixApp alloc] init:nil bundleUrl:bundleUrl runtimeUrl:runtimeUrl warningsFilter:[self getWarningFilterValue] isDeveloperApp:YES clearDataAtLaunch:NO];
[ReactNative.instance setup:mendixApp launchOptions:launchOptions];
dispatch_after(2.0, dispatch_get_main_queue(), ^(void){
[ReactNative.instance start];
});
return isHandled;
}
- (WarningsFilter) getWarningFilterValue {
#if DEBUG
return all;
#else
return [AppPreferences devModeEnabled] ? partial : none;
#endif
}
- (void) showUnrecoverableDialogWithTitle:(NSString *)title message:(NSString *) message {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[NSException raise:@"UnrecoverableError" format:message];
}]];
[self.window.rootViewController presentViewController:alertController animated:YES completion:nil];
}
- (void) setupUI {
if (@available(iOS 13.4, *)) {
[UIDatePicker appearance].preferredDatePickerStyle = UIDatePickerStyleWheels;
}
}
- (void) clearKeychain {
if ([NSUserDefaults.standardUserDefaults boolForKey:@"HAS_RUN_BEFORE"] == NO) {
[NSUserDefaults.standardUserDefaults setBool:YES forKey:@"HAS_RUN_BEFORE"];
[ReactNative clearKeychain];
}
}
@end