diff --git a/CHANGELOG.md b/CHANGELOG.md index d67acb9c..0d5912ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixes - We have fixed the textinputs hiding behind on-screen keyboard. +- We migrated iOS to the UIKit scene delegate lifecycle. ### Changes diff --git a/ios/DeveloperApp/AppDelegate.swift b/ios/DeveloperApp/AppDelegate.swift index 8ad1def5..8ddf66a1 100644 --- a/ios/DeveloperApp/AppDelegate.swift +++ b/ios/DeveloperApp/AppDelegate.swift @@ -5,50 +5,20 @@ import UserNotifications import MendixNative @main -class AppDelegate: ReactAppProvider { - - var shouldLaunchLastApp: Bool = false - var previewingSampleApp: Bool = false - - override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { +class AppDelegate: LegacyWindowAppDelegate { + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { SessionCookieStore.restore() //iOS does not persist session cookies across app restarts, this helps persisting session cookies to match behaviour with Android - setUpProvider() clearKeychainIfNecessary() setUpDevice() setUpGoogleMaps() setUpPushNotifications(application) - updateRootViewController(showOnboarding() ? .launchTutorial : .openApp) - return super.application(application, didFinishLaunchingWithOptions: launchOptions) - } - - func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { - RCTLinkingManager.application(app, open: url, options: options) - guard let appUrl = AppPreferences.appUrl, !appUrl.isEmpty, !ReactAppProvider.isReactAppActive() else { - return true - } - var launchOptions: [AnyHashable: Any] = options - launchOptions[UIApplication.LaunchOptionsKey.annotation] = options[UIApplication.OpenURLOptionsKey.annotation] ?? [] - launchOptions[UIApplication.LaunchOptionsKey.url] = url - launchMendixAppWithOptions(options: launchOptions) return true } - - 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 - } 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 } - - private func launchMendixAppWithOptions(options: [AnyHashable: Any] = [:]) { - ReactNative.shared.setup(MendixAppEntryType.deeplink.mendixApp, launchOptions: options) - ReactNative.shared.start() - } - - static func delegateInstance() -> AppDelegate? { - return UIApplication.shared.delegate as? AppDelegate - } } //Device @@ -66,21 +36,6 @@ extension AppDelegate { } } -//RootView -extension AppDelegate { - private func updateRootViewController(_ storyboard: UIStoryboard) { - window = UIWindow(frame: UIScreen.main.bounds) - window?.rootViewController = storyboard.instantiateInitialViewController() - window?.makeKeyAndVisible() - window?.overrideUserInterfaceStyle = .light // Force Light Mode - IQKeyboardManager.shared().isEnabled = false - } - - func changeRootViewToOpenApp() { - updateRootViewController(.openApp) - } -} - //GMS extension AppDelegate { private func setUpGoogleMaps() { diff --git a/ios/DeveloperApp/DeveloperApp-Bridging-Header.h b/ios/DeveloperApp/DeveloperApp-Bridging-Header.h index bf2f22ce..88334264 100644 --- a/ios/DeveloperApp/DeveloperApp-Bridging-Header.h +++ b/ios/DeveloperApp/DeveloperApp-Bridging-Header.h @@ -1,4 +1,3 @@ #import "React/RCTRootView.h" -#import "React/RCTLinkingManager.h" #import "IQKeyboardManager/IQKeyboardManager.h" #import diff --git a/ios/DeveloperApp/Info.plist b/ios/DeveloperApp/Info.plist index b3a78ff8..3c8f4dac 100644 --- a/ios/DeveloperApp/Info.plist +++ b/ios/DeveloperApp/Info.plist @@ -130,6 +130,23 @@ SimpleLineIcons.ttf Zocial.ttf + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + UIBackgroundModes fetch diff --git a/ios/DeveloperApp/MendixApp/MendixAppViewController.swift b/ios/DeveloperApp/MendixApp/MendixAppViewController.swift index ec5cef08..8bbece67 100644 --- a/ios/DeveloperApp/MendixApp/MendixAppViewController.swift +++ b/ios/DeveloperApp/MendixApp/MendixAppViewController.swift @@ -15,7 +15,7 @@ class MendixAppViewController: UIViewController, ReactNativeDelegateInternal { // Set all orientations available while launching the mendix app. AppDelegate.orientationLock = .all - AppDelegate.delegateInstance()?.window?.overrideUserInterfaceStyle = .unspecified + SceneDelegate.delegateInstance()?.window?.overrideUserInterfaceStyle = .unspecified ReactNative.shared.delegate = self ReactNative.shared.start() } @@ -30,12 +30,12 @@ class MendixAppViewController: UIViewController, ReactNativeDelegateInternal { super.viewDidDisappear(animated) // Set orientation to only portrait mode, while exiting the mendix app. AppDelegate.orientationLock = .portrait - AppDelegate.delegateInstance()?.window?.overrideUserInterfaceStyle = .light + SceneDelegate.delegateInstance()?.window?.overrideUserInterfaceStyle = .light } func onAppClosed() { - if let appDelegate = AppDelegate.delegateInstance(), appDelegate.previewingSampleApp == true { - appDelegate.previewingSampleApp = false + if let sceneDelegate = SceneDelegate.delegateInstance(), sceneDelegate.previewingSampleApp == true { + sceneDelegate.previewingSampleApp = false StorageHelper.clearAll() } self.navigationController?.popViewController(animated: true) diff --git a/ios/DeveloperApp/OpenApp/OpenAppViewController.swift b/ios/DeveloperApp/OpenApp/OpenAppViewController.swift index 11eeed92..59ad1e2a 100644 --- a/ios/DeveloperApp/OpenApp/OpenAppViewController.swift +++ b/ios/DeveloperApp/OpenApp/OpenAppViewController.swift @@ -6,9 +6,8 @@ class OpenAppViewController: UIViewController { self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default) - let appDelegate = (UIApplication.shared.delegate as! AppDelegate) - if (appDelegate.shouldLaunchLastApp) { - appDelegate.shouldLaunchLastApp = false; + if let sceneDelegate = SceneDelegate.delegateInstance(), sceneDelegate.shouldLaunchLastApp { + sceneDelegate.shouldLaunchLastApp = false; self.performSegue(withIdentifier: "MendixApp", sender: nil) } } diff --git a/ios/DeveloperApp/OpenApp/TabViewController.swift b/ios/DeveloperApp/OpenApp/TabViewController.swift index b63379bd..59684c9a 100644 --- a/ios/DeveloperApp/OpenApp/TabViewController.swift +++ b/ios/DeveloperApp/OpenApp/TabViewController.swift @@ -16,8 +16,8 @@ class TabViewController: UITabBarController { } func setSelectedIndex(index:Int){ - guard let appDelegate = UIApplication.shared.delegate as? AppDelegate, - let tabBarController = appDelegate.window?.rootViewController as? UITabBarController else { + guard let sceneDelegate = SceneDelegate.delegateInstance(), + let tabBarController = sceneDelegate.window?.rootViewController as? UITabBarController else { return } tabBarController.selectedIndex = index diff --git a/ios/DeveloperApp/SampleApps/SampleAppCollectionViewController.swift b/ios/DeveloperApp/SampleApps/SampleAppCollectionViewController.swift index 2fc877fb..e92ab8f7 100644 --- a/ios/DeveloperApp/SampleApps/SampleAppCollectionViewController.swift +++ b/ios/DeveloperApp/SampleApps/SampleAppCollectionViewController.swift @@ -38,8 +38,7 @@ class SampleAppCollectionViewController: UIViewController { } func onTap(app: SampleApp) { - let appDelegate = (UIApplication.shared.delegate as! AppDelegate) - appDelegate.previewingSampleApp = true + SceneDelegate.delegateInstance()?.previewingSampleApp = true for i in 0..) { + handleURLContexts(URLContexts) { [weak self] launchOptions in + self?.launchMendixAppWithOptions(options: launchOptions) + } + } + + @objc func sceneDidEnterBackground(_ scene: UIScene) { + SessionCookieStore.persist() //iOS does not persist session cookies across app restarts, this helps persisting session cookies to match behaviour with Android + } + + private func launchMendixAppWithOptions(options: [AnyHashable: Any]) { + guard let appUrl = AppPreferences.appUrl, !appUrl.isEmpty else { + return + } + ReactNative.shared.setup(MendixAppEntryType.deeplink.mendixApp, launchOptions: options) + ReactNative.shared.start() + } + + static func delegateInstance() -> SceneDelegate? { + if let provider = ReactAppProvider.shared() as? SceneDelegate { + return provider + } + return UIApplication.shared.connectedScenes.compactMap { $0.delegate as? SceneDelegate }.first + } +} + +//RootView +extension SceneDelegate { + private func updateRootViewController(_ storyboard: UIStoryboard) { + guard let rootViewController = storyboard.instantiateInitialViewController() else { + return + } + changeRoot(to: rootViewController) + window?.overrideUserInterfaceStyle = .light + IQKeyboardManager.shared().isEnabled = false + } + + func changeRootViewToOpenApp() { + updateRootViewController(.openApp) + } +} diff --git a/ios/DeveloperApp/Tutorial/LaunchTutorialViewController.swift b/ios/DeveloperApp/Tutorial/LaunchTutorialViewController.swift index ed243de6..ed7b1450 100644 --- a/ios/DeveloperApp/Tutorial/LaunchTutorialViewController.swift +++ b/ios/DeveloperApp/Tutorial/LaunchTutorialViewController.swift @@ -22,7 +22,7 @@ class LaunchTutorialViewController: UIViewController { } private func closeOnboarding() { - AppDelegate.delegateInstance()?.changeRootViewToOpenApp() + SceneDelegate.delegateInstance()?.changeRootViewToOpenApp() } private func setupSwiftUIScreen(){ diff --git a/ios/Podfile b/ios/Podfile index c5a785c6..cd808be5 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -75,6 +75,12 @@ target 'DeveloperApp' do 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 target.name.start_with?('React') || target.name == 'RCTTypeSafety' config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [] diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 7fac32f8..aaeb0e37 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -167,7 +167,7 @@ PODS: - libwebp/sharpyuv (1.5.0) - libwebp/webp (1.5.0): - libwebp/sharpyuv - - MendixNative (0.5.0): + - MendixNative (0.5.3): - hermes-engine - RCTRequired - RCTTypeSafety @@ -3399,10 +3399,10 @@ SPEC CHECKSUMS: GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a GoogleMaps: 8939898920281c649150e0af74aa291c60f2e77d GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15 - hermes-engine: 166613ab57f3dde1bf3f24c60212b66a1d585f8b + hermes-engine: 9f6d216d03a4100ed243774d56948a93afc5bae1 IQKeyboardManager: c8665b3396bd0b79402b4c573eac345a31c7d485 libwebp: 02b23773aedb6ff1fd38cec7a77b81414c6842a8 - MendixNative: 7cba944a4e608e6ab40ec281e9b2b0f9f3cdefe0 + MendixNative: 9eafc82c338dad09bdd25536d66ae9afe26945a8 MultiplatformBleAdapter: b1fddd0d499b96b607e00f0faa8e60648343dc1d nanopb: 438bc412db1928dac798aa6fd75726007be04262 NitroGeolocation: 688a2b889656060dafe9d83dc62fc0513b954a97 @@ -3420,7 +3420,7 @@ SPEC CHECKSUMS: React: 1ba7d364ade7d883a1ec055bfc3606f35fdee17b React-callinvoker: bc2a26f8d84fb01f003fc6de6c9337b64715f95b React-Core: 7840d3a80b43a95c5e80ef75146bd70925ebab0f - React-Core-prebuilt: 2439654d53489a5609231fe950d7f4e4c641ad52 + React-Core-prebuilt: a54db89db007bc34115efc5abe10e05c699797da React-CoreModules: 2eb010400b63b89e53a324ffb3c112e4c7c3ce42 React-cxxreact: a558e92199d26f145afa9e62c4233cf8e7950efe React-debug: 755200a6e7f5e6e0a40ff8d215493d43cce285fc @@ -3499,7 +3499,7 @@ SPEC CHECKSUMS: ReactCodegen: 797de5178718324c6eba3327b07f9a423fbd5787 ReactCommon: 07572bf9e687c8a52fbe4a3641e9e3a1a477c78e ReactNativeBiometrics: 9ead8d633833fd13e5a79564af8ba7064c2a58c6 - ReactNativeDependencies: 14132e559d3008cd261e3c00859a58fd4f7fa42c + ReactNativeDependencies: e709c771664b1e4e11acf00936c61a975577bf9c RNBootSplash: 13b7612788960d0c5446e68489ac2509e506cfcd RNCalendarEvents: f90f73666b6bcbb3cc8a491ffbb5e48c0db3de37 RNCAsyncStorage: 3a4f5e2777dae1688b781a487923a08569e27fe4 @@ -3530,6 +3530,6 @@ SPEC CHECKSUMS: VisionCamera: 7187b3dac1ff3071234ead959ce311875748e14f Yoga: c0b3f2c7e8d3e327e450223a2414ca3fa296b9a2 -PODFILE CHECKSUM: 3ac57498e7a5b50e63c45224f2a40431ea916f8c +PODFILE CHECKSUM: d353966f749dab43419e63883c1943d86361ce21 COCOAPODS: 1.16.2 diff --git a/ios/developerapp.xcodeproj/project.pbxproj b/ios/developerapp.xcodeproj/project.pbxproj index 4b4aef1c..5e1c8068 100644 --- a/ios/developerapp.xcodeproj/project.pbxproj +++ b/ios/developerapp.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 04222F8220403EC30092F0A0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04222F8120403EC30092F0A0 /* AppDelegate.swift */; }; + 04222F8420403EC30092F0A0 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04222F8320403EC30092F0A0 /* SceneDelegate.swift */; }; 0433D0C820878BA6001EDC7B /* PaddingTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0433D0C720878BA6001EDC7B /* PaddingTextField.swift */; }; 046CD08F20406110007291F9 /* OpenAppViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 046CD08E20406110007291F9 /* OpenAppViewController.swift */; }; 047B674A22B1080200FF5FC3 /* Bundles in Resources */ = {isa = PBXBuildFile; fileRef = 047B674922B1080200FF5FC3 /* Bundles */; }; @@ -89,6 +90,7 @@ /* Begin PBXFileReference section */ 04222F8120403EC30092F0A0 /* AppDelegate.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; tabWidth = 2; wrapsLines = 1; }; + 04222F8320403EC30092F0A0 /* SceneDelegate.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; tabWidth = 2; wrapsLines = 1; }; 0433D0C720878BA6001EDC7B /* PaddingTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaddingTextField.swift; sourceTree = ""; }; 046CD08E20406110007291F9 /* OpenAppViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenAppViewController.swift; sourceTree = ""; }; 047B674922B1080200FF5FC3 /* Bundles */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Bundles; sourceTree = ""; }; @@ -285,6 +287,7 @@ 13B07FB61A68108700A75B9A /* Info.plist */, 6EAD388C2A3B439F00DC9D88 /* Launch */, 04222F8120403EC30092F0A0 /* AppDelegate.swift */, + 04222F8320403EC30092F0A0 /* SceneDelegate.swift */, 2CCCE91825A367F80087AD16 /* Colors.xcassets */, 2C887F5B24B78D640003DC53 /* SplashScreenPresenter.swift */, EB07BDA720CEA13400E0CD48 /* Images.xcassets */, @@ -678,6 +681,7 @@ 1055849E2A8DF9950015F9E0 /* SampleApps.swift in Sources */, E7EF3D242A33474400A04EA8 /* LaunchScreenStateManager.swift in Sources */, 04222F8220403EC30092F0A0 /* AppDelegate.swift in Sources */, + 04222F8420403EC30092F0A0 /* SceneDelegate.swift in Sources */, 6E1EA91C2A4AD72B00C430A4 /* LaunchScreenViewController.swift in Sources */, 6E6C9B402A406C99002F788D /* HelpListTile.swift in Sources */, 2C887F5C24B78D640003DC53 /* SplashScreenPresenter.swift in Sources */, diff --git a/package-lock.json b/package-lock.json index d3d03e9a..3bd7d090 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "@sbaiahmed1/react-native-biometrics": "0.10.0", "@shopify/flash-list": "2.3.1", "@swan-io/react-native-browser": "1.0.1", - "mendix-native": "https://github.com/mendix/mendix-native/releases/download/v0.5.0/mendix-native-v0.5.0.tgz", + "mendix-native": "https://github.com/mendix/mendix-native/releases/download/v0.5.3/mendix-native-v0.5.3.tgz", "react-native": "0.84.1", "react-native-ble-plx": "3.5.1", "react-native-blob-util": "0.24.7", @@ -5167,9 +5167,9 @@ "license": "MIT" }, "node_modules/mendix-native": { - "version": "0.5.0", - "resolved": "https://github.com/mendix/mendix-native/releases/download/v0.5.0/mendix-native-v0.5.0.tgz", - "integrity": "sha512-iyECE41zVvHj8SzvzqiP10JjFsoEBP3cKPV/qyZuk2frcjcrel1IJAZiLGC9AlsWp9AjaC0aDfhci/Lzisnx+g==", + "version": "0.5.3", + "resolved": "https://github.com/mendix/mendix-native/releases/download/v0.5.3/mendix-native-v0.5.3.tgz", + "integrity": "sha512-xWlxcZniz3/7K9NZQx31lZyDeGJPTs4iPA0IccbywvZ/RUIOJPZM2EduNIjfsjuan6j8GOElN+seHPHfSHm+Gw==", "license": "MIT", "workspaces": [ "example" diff --git a/package.json b/package.json index 16b9fde3..b2c1939d 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ }, "dependencies": { "@gorhom/bottom-sheet": "5.2.14", - "mendix-native": "https://github.com/mendix/mendix-native/releases/download/v0.5.0/mendix-native-v0.5.0.tgz", + "mendix-native": "https://github.com/mendix/mendix-native/releases/download/v0.5.3/mendix-native-v0.5.3.tgz", "@octokit/rest": "^21.1.1", "@op-engineering/op-sqlite": "15.2.5", "@shopify/flash-list": "2.3.1",