|
| 1 | +import MendixNative |
| 2 | + |
| 3 | +@UIApplicationMain |
| 4 | +class AppDelegate: ReactAppProvider, UNUserNotificationCenterDelegate { |
| 5 | + |
| 6 | + var shouldOpenInLastApp = false |
| 7 | + var hasHandledLaunchAppWithOptions = false |
| 8 | + |
| 9 | + override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { |
| 10 | + |
| 11 | + setUpProvider() |
| 12 | + super.application(application, didFinishLaunchingWithOptions: launchOptions) |
| 13 | + |
| 14 | + clearKeychain() |
| 15 | + MendixAppDelegate.delegate = self |
| 16 | + UNUserNotificationCenter.current().delegate = self |
| 17 | + MendixAppDelegate.application(application, didFinishLaunchingWithOptions: launchOptions) |
| 18 | + setupUI() |
| 19 | + |
| 20 | + changeRoot(to: UIViewController()) |
| 21 | + |
| 22 | + guard let url = Bundle.main.object(forInfoDictionaryKey: "Runtime url") as? String, !url.isEmpty else { |
| 23 | + showUnrecoverableDialog( |
| 24 | + title: "The runtime URL is missing", |
| 25 | + message: "Missing the 'Runtime url' configuration within the Info.plist file. The app will close." |
| 26 | + ) |
| 27 | + return false |
| 28 | + } |
| 29 | + |
| 30 | + if let bundleUrl = MendixAppDelegate.getJSBundleFile() { |
| 31 | + let runtimeUrl = AppUrl.forRuntime((url).replacingOccurrences(of: "\\", with: "")) |
| 32 | + |
| 33 | + |
| 34 | + let mendixApp = MendixApp( |
| 35 | + identifier: nil, |
| 36 | + bundleUrl: bundleUrl, |
| 37 | + runtimeUrl: runtimeUrl, |
| 38 | + warningsFilter: .none, |
| 39 | + isDeveloperApp: false, |
| 40 | + clearDataAtLaunch: false, |
| 41 | + splashScreenPresenter: SplashScreenPresenter(), |
| 42 | + reactLoading: nil, |
| 43 | + enableThreeFingerGestures: false |
| 44 | + ) |
| 45 | + |
| 46 | + ReactNative.shared.setup(mendixApp, launchOptions: launchOptions) |
| 47 | + ReactNative.shared.start() |
| 48 | + } else { |
| 49 | + showUnrecoverableDialog( |
| 50 | + title: "No Mendix bundle found", |
| 51 | + message: "Missing the Mendix app bundle. Make sure that the index.ios.bundle file is available in ios/NativeTemplate/Bundle folder. If building locally consult the documentation on how to generate a bundle from your project." |
| 52 | + ) |
| 53 | + } |
| 54 | + |
| 55 | + return true |
| 56 | + } |
| 57 | + |
| 58 | + override func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { |
| 59 | + return MendixAppDelegate.application(app, openURL: url, options: options) |
| 60 | + } |
| 61 | + |
| 62 | + func getWarningFilterValue() -> WarningsFilter { |
| 63 | + return .none |
| 64 | + } |
| 65 | + |
| 66 | + func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { |
| 67 | + MendixAppDelegate.userNotificationCenter(center, willPresentNotification: notification, withCompletionHandler: completionHandler) |
| 68 | + } |
| 69 | + |
| 70 | + |
| 71 | +// - (void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { |
| 72 | +// [MendixAppDelegate application:application didReceiveLocalNotification:notification]; |
| 73 | +// } |
| 74 | +// |
| 75 | +// - (void) application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo |
| 76 | +// fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{ |
| 77 | +// [MendixAppDelegate application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; |
| 78 | +// } |
| 79 | +// |
| 80 | +// - (void) application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { |
| 81 | +// [MendixAppDelegate application:application didRegisterUserNotificationSettings:notificationSettings]; |
| 82 | +// } |
| 83 | +// |
| 84 | +// - (void) userNotificationCenter:(UNUserNotificationCenter *)center |
| 85 | +// didReceiveNotificationResponse:(UNNotificationResponse *)response |
| 86 | +// withCompletionHandler:(void (^)(void))completionHandler { |
| 87 | +// [MendixAppDelegate userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler]; |
| 88 | +// } |
| 89 | +} |
0 commit comments