Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 18 additions & 59 deletions ios/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,67 +1,26 @@
import UIKit
import MendixNative

@UIApplicationMain
class AppDelegate: ReactAppProvider {

var shouldOpenInLastApp = false
var hasHandledLaunchAppWithOptions = false

override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

SessionCookieStore.restore() // iOS does not persist session cookies across app restarts, this helps persisting session cookies to match behaviour with Android
@main
class AppDelegate: UIResponder, UIApplicationDelegate {

@objc var window: UIWindow? {
get { SceneDelegate.delegateInstance()?.window }
set { SceneDelegate.delegateInstance()?.window = newValue }
}

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
SessionCookieStore.restore()
MendixAppDelegate.application(application, didFinishLaunchingWithOptions: launchOptions)
setupApp(application: application, launchOptions: launchOptions)
changeRoot(to: UIViewController())

guard let url = Bundle.main.object(forInfoDictionaryKey: "Runtime url") as? String, !url.isEmpty else {
showUnrecoverableDialog(
title: "The runtime URL is missing",
message: "Missing the 'Runtime url' configuration within the Info.plist file. The app will close."
)
return false
}

if let bundleUrl = MendixAppDelegate.getJSBundleFile() {

let runtimeUrl = AppUrl.forRuntime((url).replacingOccurrences(of: "\\", with: ""))

let mendixApp = MendixApp(
identifier: nil,
bundleUrl: bundleUrl,
runtimeUrl: runtimeUrl,
warningsFilter: .none,
isDeveloperApp: false,
clearDataAtLaunch: false,
splashScreenPresenter: SplashScreenPresenter(),
reactLoading: nil,
enableThreeFingerGestures: false
)

ReactNative.shared.setup(mendixApp, launchOptions: launchOptions)
ReactNative.shared.start()
} else {
showUnrecoverableDialog(
title: "No Mendix bundle found",
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."
)
}

clearKeychain()
setupUI()
return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
return MendixAppDelegate.application(app, openURL: url, options: options)
}

func getWarningFilterValue() -> WarningsFilter {
return .none
}


func applicationWillTerminate(_ application: UIApplication) {
SessionCookieStore.persist() // iOS does not persist session cookies across app restarts, this helps persisting session cookies to match behaviour with Android
}

func applicationDidEnterBackground(_ application: UIApplication) {
SessionCookieStore.persist() // iOS does not persist session cookies across app restarts, this helps persisting session cookies to match behaviour with Android
SessionCookieStore.persist()
}
}
89 changes: 18 additions & 71 deletions ios/Dev/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,79 +1,26 @@
import Foundation
import UIKit
import MendixNative

@UIApplicationMain
class AppDelegate: ReactAppProvider {

var shouldOpenInLastApp = false
var hasHandledLaunchAppWithOptions = false

override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

SessionCookieStore.restore() //iOS does not persist session cookies across app restarts, this helps persisting session cookies to match behaviour with Android
@main
class AppDelegate: UIResponder, UIApplicationDelegate {

@objc var window: UIWindow? {
get { SceneDelegate.delegateInstance()?.window }
set { SceneDelegate.delegateInstance()?.window = newValue }
}

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
SessionCookieStore.restore()
MendixAppDelegate.application(application, didFinishLaunchingWithOptions: launchOptions)
setupApp(application: application, launchOptions: launchOptions)

IQKeyboardManager.shared().isEnabled = false

let controller = UIStoryboard.launchApp.instantiateInitialViewController() ?? UIViewController()
changeRoot(to: controller)
window?.isUserInteractionEnabled = true

clearKeychain()
setupUI()
return true
}

func getWarningFilterValue() -> WarningsFilter {
#if DEBUG
return .all
#else
return AppPreferences.devModeEnabled ? .partial : .none
#endif
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

let handled = MendixAppDelegate.application(app, openURL: url, options: options)

let appUrl = AppPreferences.safeAppUrl

if (!handled || appUrl.isEmpty || ReactAppProvider.isReactAppActive()) {
return false
}

let bundleUrl = AppUrl.forBundle(
appUrl,
port: AppPreferences.remoteDebuggingPackagerPort,
isDebuggingRemotely: AppPreferences.remoteDebuggingEnabled,
isDevModeEnabled: AppPreferences.devModeEnabled
)

let launchOptions = NSMutableDictionary(dictionary: options)
launchOptions[UIApplication.LaunchOptionsKey.url] = url
launchOptions[UIApplication.OpenURLOptionsKey.annotation] = options[UIApplication.OpenURLOptionsKey.annotation]

let mxApp = MendixApp.init(
identifier: nil,
bundleUrl: bundleUrl,
runtimeUrl: AppUrl.forRuntime(appUrl),
warningsFilter: getWarningFilterValue(),
isDeveloperApp: true,
clearDataAtLaunch: false,
splashScreenPresenter: nil,
reactLoading: nil,
enableThreeFingerGestures: false
)

ReactNative.shared.setup(mxApp, launchOptions: launchOptions as? [AnyHashable : Any])
ReactNative.shared.start()

return handled
}


func applicationWillTerminate(_ application: UIApplication) {
SessionCookieStore.persist() //iOS does not persist session cookies across app restarts, this helps persisting session cookies to match behaviour with Android
}

func applicationDidEnterBackground(_ application: UIApplication) {
SessionCookieStore.persist() //iOS does not persist session cookies across app restarts, this helps persisting session cookies to match behaviour with Android
SessionCookieStore.persist()
}
}
6 changes: 3 additions & 3 deletions ios/Dev/LaunchApp/LaunchAppViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ class LaunchAppViewController: UIViewController, QRViewDelegate {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

let appDelegate = (UIApplication.shared.delegate as! AppDelegate);
if (appDelegate.shouldOpenInLastApp) {
appDelegate.shouldOpenInLastApp = false;
guard let sceneDelegate = SceneDelegate.delegateInstance() else { return }
if (sceneDelegate.shouldOpenInLastApp) {
sceneDelegate.shouldOpenInLastApp = false
self.performSegue(withIdentifier: "MendixApp", sender: nil)
}
}
Expand Down
81 changes: 81 additions & 0 deletions ios/Dev/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import UIKit
import MendixNative

class SceneDelegate: ReactAppProvider {

var shouldOpenInLastApp = false
var hasHandledLaunchAppWithOptions = false

override func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
super.scene(scene, willConnectTo: session, options: connectionOptions)

setUpProvider()
IQKeyboardManager.shared().isEnabled = false

let controller = UIStoryboard.launchApp.instantiateInitialViewController() ?? UIViewController()
changeRoot(to: controller)
window?.isUserInteractionEnabled = true

if !connectionOptions.urlContexts.isEmpty {
launchMendixApp(with: ReactAppProvider.launchOptions(from: connectionOptions))
}
}

func getWarningFilterValue() -> WarningsFilter {
#if DEBUG
return .all
#else
return AppPreferences.devModeEnabled ? .partial : .none
#endif
}

override func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
handleURLContexts(URLContexts) { [weak self] launchOptions in
self?.launchMendixApp(with: launchOptions)
}
}

private func launchMendixApp(with launchOptions: [AnyHashable: Any]) {
let appUrl = AppPreferences.safeAppUrl

guard !appUrl.isEmpty else { return }

let bundleUrl = AppUrl.forBundle(
appUrl,
port: AppPreferences.remoteDebuggingPackagerPort,
isDebuggingRemotely: AppPreferences.remoteDebuggingEnabled,
isDevModeEnabled: AppPreferences.devModeEnabled
)

let mxApp = MendixApp(
identifier: nil,
bundleUrl: bundleUrl,
runtimeUrl: AppUrl.forRuntime(appUrl),
warningsFilter: getWarningFilterValue(),
isDeveloperApp: true,
clearDataAtLaunch: false,
splashScreenPresenter: nil,
reactLoading: nil,
enableThreeFingerGestures: false
)

ReactNative.shared.setup(mxApp, launchOptions: launchOptions)
ReactNative.shared.start()
}

@objc func sceneDidEnterBackground(_ scene: UIScene) {
SessionCookieStore.persist()
}

static func delegateInstance() -> SceneDelegate? {
if let provider = ReactAppProvider.shared() as? SceneDelegate {
return provider
}
return UIApplication.shared.connectedScenes.compactMap { $0.delegate as? SceneDelegate }.first
}

}
15 changes: 0 additions & 15 deletions ios/Extensions/AppDelegate+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,4 @@ extension AppDelegate {
func setupUI() {
UIDatePicker.appearance().preferredDatePickerStyle = .wheels
}

func showUnrecoverableDialog(title: String, message: String) {
let controller = UIAlertController(title: title, message: message, preferredStyle: .alert)
controller.addAction(.init(title: "Close", style: .default, handler: {_ in
print(message)
exit(0)
}))
window?.rootViewController?.present(controller, animated: true, completion: nil)
}

func setupApp(application: UIApplication, launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) {
setUpProvider()
clearKeychain()
setupUI()
}
}
7 changes: 7 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ post_install do |installer|

installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|

minimum_ios_version = Gem::Version.new(deployment_target)
current_deployment_target = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
if current_deployment_target && Gem::Version.new(current_deployment_target) < minimum_ios_version
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
end

if config.name == "ReleaseDevApp"
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= []
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] |= ['$(inherited)', 'NDEBUG=1', 'REACT_NATIVE_DEBUG=1']
Expand Down
14 changes: 7 additions & 7 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ PODS:
- libwebp/sharpyuv (1.5.0)
- libwebp/webp (1.5.0):
- libwebp/sharpyuv
- MendixNative (0.5.1):
- MendixNative (0.5.2):
- hermes-engine
- RCTRequired
- RCTTypeSafety
Expand Down Expand Up @@ -2902,12 +2902,12 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
FBLazyVector: e97c19a5a442429d1988f182a1940fb08df514da
hermes-engine: 67c41b335723f72b2a182dbaeeebd97a73fc2775
hermes-engine: 69685c8bd68491a4ff7f075256f5b2dfab04de21
IQKeyboardManager: c8665b3396bd0b79402b4c573eac345a31c7d485
libavif: 84bbb62fb232c3018d6f1bab79beea87e35de7b7
libdav1d: 23581a4d8ec811ff171ed5e2e05cd27bad64c39f
libwebp: 02b23773aedb6ff1fd38cec7a77b81414c6842a8
MendixNative: b0ea153b893ce40b90016f397e9a5acfe4444c33
MendixNative: b789c95cb7e776e332a0dabd4f39b91e20c1f31d
op-sqlite: e9ef65bcf95a97863874cee87841425bb71c8396
OpenSSL-Universal: 6082b0bf950e5636fe0d78def171184e2b3899c2
RCTDeprecation: af44b104091a34482596cd9bd7e8d90c4e9b4bd7
Expand All @@ -2918,7 +2918,7 @@ SPEC CHECKSUMS:
React: 1ba7d364ade7d883a1ec055bfc3606f35fdee17b
React-callinvoker: bc2a26f8d84fb01f003fc6de6c9337b64715f95b
React-Core: 7840d3a80b43a95c5e80ef75146bd70925ebab0f
React-Core-prebuilt: 24a3f8fa32b407405d9e1085d3b09014f79c0870
React-Core-prebuilt: 203358738dba539388b07a09a926858081125bc1
React-CoreModules: 2eb010400b63b89e53a324ffb3c112e4c7c3ce42
React-cxxreact: a558e92199d26f145afa9e62c4233cf8e7950efe
React-debug: 755200a6e7f5e6e0a40ff8d215493d43cce285fc
Expand Down Expand Up @@ -2988,7 +2988,7 @@ SPEC CHECKSUMS:
ReactAppDependencyProvider: e96e93b493d8d86eeaee3e590ba0be53f6abe46f
ReactCodegen: 797de5178718324c6eba3327b07f9a423fbd5787
ReactCommon: 07572bf9e687c8a52fbe4a3641e9e3a1a477c78e
ReactNativeDependencies: 061101f5e362f1f5d0687dd5b92432f7b76f4317
ReactNativeDependencies: 770e0777d2bd1891fd654bdbb3da9e9905a96394
RNBootSplash: 13b7612788960d0c5446e68489ac2509e506cfcd
RNCAsyncStorage: 3a4f5e2777dae1688b781a487923a08569e27fe4
RNCPicker: c8a3584b74133464ee926224463fcc54dfdaebca
Expand All @@ -3011,6 +3011,6 @@ SPEC CHECKSUMS:
SwiftAudioEx: f6aa653770f3a0d3851edaf8d834a30aee4a7646
Yoga: c0b3f2c7e8d3e327e450223a2414ca3fa296b9a2

PODFILE CHECKSUM: 7a33012cce520784bb5b691549f5ed2af273b7e3
PODFILE CHECKSUM: 8d31f00ca87f4bcff1bd77f07e1f39545e895320

COCOAPODS: 1.17.0
COCOAPODS: 1.16.2
Loading
Loading