diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/.swiftpm/xcode/package.xcworkspace/xcuserdata/vlad.paianu.xcuserdatad/UserInterfaceState.xcuserstate b/.swiftpm/xcode/package.xcworkspace/xcuserdata/vlad.paianu.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..6132bda Binary files /dev/null and b/.swiftpm/xcode/package.xcworkspace/xcuserdata/vlad.paianu.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/.swiftpm/xcode/xcuserdata/vlad.paianu.xcuserdatad/xcschemes/xcschememanagement.plist b/.swiftpm/xcode/xcuserdata/vlad.paianu.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..7b5fc4b --- /dev/null +++ b/.swiftpm/xcode/xcuserdata/vlad.paianu.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,48 @@ + + + + + SchemeUserState + + GeotabMobileSDK.xcscheme_^#shared#^_ + + orderHint + 0 + + Playground (Playground) 1.xcscheme + + isShown + + orderHint + 2 + + Playground (Playground) 2.xcscheme + + isShown + + orderHint + 3 + + Playground (Playground).xcscheme + + isShown + + orderHint + 1 + + + SuppressBuildableAutocreation + + GeotabMobileSDK + + primary + + + GeotabMobileSDK_GeotabMobileSDK + + primary + + + + + diff --git a/Package.swift b/Package.swift index bd5b0dc..a33fb8b 100644 --- a/Package.swift +++ b/Package.swift @@ -31,9 +31,5 @@ let package = Package( "native-sdk.d.ts"], resources: [ .process("Assets")]), - .testTarget( - name: "GeotabMobileSDKTests", - dependencies: ["GeotabMobileSDK"], - exclude: ["Info.plist", "rulesets.json"]), ] ) diff --git a/Sources/GeotabMobileSDK/Classes/DriveViewController.swift b/Sources/GeotabMobileSDK/Classes/DriveViewController.swift index 8cf6f55..5e9332d 100644 --- a/Sources/GeotabMobileSDK/Classes/DriveViewController.swift +++ b/Sources/GeotabMobileSDK/Classes/DriveViewController.swift @@ -302,7 +302,7 @@ extension DriveViewController: WKUIDelegate { public func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) { - guard let bundle = languageBundle else { + guard let bundle = languageBundle, isPresentInViewHierarchy, !(presentedViewController is UIAlertController) else { completionHandler() return } @@ -319,7 +319,7 @@ extension DriveViewController: WKUIDelegate { public func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) { - guard let bundle = languageBundle else { + guard let bundle = languageBundle, isPresentInViewHierarchy, !(presentedViewController is UIAlertController) else { completionHandler(false) return } @@ -335,7 +335,7 @@ extension DriveViewController: WKUIDelegate { alertController.addAction(UIAlertAction(title: cancelText, style: .cancel, handler: { _ in completionHandler(false) })) - + self.present(alertController, animated: true, completion: nil) } diff --git a/Sources/GeotabMobileSDK/Classes/Extensions/UIViewController-Extension.swift b/Sources/GeotabMobileSDK/Classes/Extensions/UIViewController-Extension.swift new file mode 100644 index 0000000..b459d0c --- /dev/null +++ b/Sources/GeotabMobileSDK/Classes/Extensions/UIViewController-Extension.swift @@ -0,0 +1,14 @@ +// +// UIViewController-Extension.swift +// +// +// Created by vlad.paianu on 02.08.2023. +// + +import UIKit + +extension UIViewController { + var isPresentInViewHierarchy: Bool { + return isViewLoaded && view.window != nil + } +}