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
60 changes: 12 additions & 48 deletions ios/DeveloperApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,29 @@ 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: UIResponder, UIApplicationDelegate {

/// The window lives on `SceneDelegate` under the scene lifecycle, but `UIApplicationDelegate`
/// declares `window` as an optional requirement that third party libraries still read through
/// `UIApplication.shared.delegate` (react-native-firebase, reanimated, blob-util). Without this
/// forwarding property the selector is unimplemented and those reads crash.
@objc var window: UIWindow? {
get { SceneDelegate.delegateInstance()?.window }
set { SceneDelegate.delegateInstance()?.window = newValue }
}

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
Expand All @@ -66,21 +45,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() {
Expand Down
1 change: 0 additions & 1 deletion ios/DeveloperApp/DeveloperApp-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#import "React/RCTRootView.h"
#import "React/RCTLinkingManager.h"
#import "IQKeyboardManager/IQKeyboardManager.h"
#import <RNBootSplash.h>
19 changes: 17 additions & 2 deletions ios/DeveloperApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,30 @@
<string>SimpleLineIcons.ttf</string>
<string>Zocial.ttf</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
<key>UIFileSharingEnabled</key>
<true/>
<key>UILaunchStoryboardName</key>
<string></string>
<key>UIMainStoryboardFile</key>
<string>LaunchTutorial</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
8 changes: 4 additions & 4 deletions ios/DeveloperApp/MendixApp/MendixAppViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions ios/DeveloperApp/OpenApp/OpenAppViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
4 changes: 2 additions & 2 deletions ios/DeveloperApp/OpenApp/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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..<sampleApps.count {
if sampleApps[i].id == app.id {
Expand Down
59 changes: 59 additions & 0 deletions ios/DeveloperApp/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import UIKit
import MendixNative

class SceneDelegate: ReactAppProvider {

var shouldLaunchLastApp: Bool = false
var previewingSampleApp: Bool = false

override func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
super.scene(scene, willConnectTo: session, options: connectionOptions)
setUpProvider()
updateRootViewController(showOnboarding() ? .launchTutorial : .openApp)
// A cold start triggered by a deep link delivers the URL here instead of through scene(_:openURLContexts:).
if !connectionOptions.urlContexts.isEmpty {
launchMendixAppWithOptions(options: ReactAppProvider.launchOptions(from: connectionOptions))
}
}

override func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LaunchTutorialViewController: UIViewController {
}

private func closeOnboarding() {
AppDelegate.delegateInstance()?.changeRootViewToOpenApp()
SceneDelegate.delegateInstance()?.changeRootViewToOpenApp()
}

private func setupSwiftUIScreen(){
Expand Down
6 changes: 6 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ||= []
Expand Down
12 changes: 6 additions & 6 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ PODS:
- libwebp/sharpyuv (1.5.0)
- libwebp/webp (1.5.0):
- libwebp/sharpyuv
- MendixNative (0.5.0):
- MendixNative (0.5.2):
- hermes-engine
- RCTRequired
- RCTTypeSafety
Expand Down Expand Up @@ -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: b789c95cb7e776e332a0dabd4f39b91e20c1f31d
MultiplatformBleAdapter: b1fddd0d499b96b607e00f0faa8e60648343dc1d
nanopb: 438bc412db1928dac798aa6fd75726007be04262
NitroGeolocation: 688a2b889656060dafe9d83dc62fc0513b954a97
Expand All @@ -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
Expand Down Expand Up @@ -3499,7 +3499,7 @@ SPEC CHECKSUMS:
ReactCodegen: 797de5178718324c6eba3327b07f9a423fbd5787
ReactCommon: 07572bf9e687c8a52fbe4a3641e9e3a1a477c78e
ReactNativeBiometrics: 9ead8d633833fd13e5a79564af8ba7064c2a58c6
ReactNativeDependencies: 14132e559d3008cd261e3c00859a58fd4f7fa42c
ReactNativeDependencies: e709c771664b1e4e11acf00936c61a975577bf9c
RNBootSplash: 13b7612788960d0c5446e68489ac2509e506cfcd
RNCalendarEvents: f90f73666b6bcbb3cc8a491ffbb5e48c0db3de37
RNCAsyncStorage: 3a4f5e2777dae1688b781a487923a08569e27fe4
Expand Down Expand Up @@ -3530,6 +3530,6 @@ SPEC CHECKSUMS:
VisionCamera: 7187b3dac1ff3071234ead959ce311875748e14f
Yoga: c0b3f2c7e8d3e327e450223a2414ca3fa296b9a2

PODFILE CHECKSUM: 3ac57498e7a5b50e63c45224f2a40431ea916f8c
PODFILE CHECKSUM: d353966f749dab43419e63883c1943d86361ce21

COCOAPODS: 1.16.2
Loading