diff --git a/Sources/Handler/OAuthSwiftOpenURLExternally.swift b/Sources/Handler/OAuthSwiftOpenURLExternally.swift index b807320..3ec67b3 100644 --- a/Sources/Handler/OAuthSwiftOpenURLExternally.swift +++ b/Sources/Handler/OAuthSwiftOpenURLExternally.swift @@ -8,7 +8,7 @@ import Foundation -#if os(iOS) || os(tvOS) +#if os(iOS) || os(tvOS) || os(visionOS) import UIKit #elseif os(watchOS) import WatchKit @@ -35,6 +35,8 @@ open class OAuthSwiftOpenURLExternally: OAuthSwiftURLHandlerType { // WATCHOS: not implemented #elseif os(OSX) NSWorkspace.shared.open(url) + #elseif os(visionOS) + UIApplication.shared.open(url) #endif } } diff --git a/Sources/Handler/OAuthWebViewController.swift b/Sources/Handler/OAuthWebViewController.swift index 1efb90c..5066d73 100644 --- a/Sources/Handler/OAuthWebViewController.swift +++ b/Sources/Handler/OAuthWebViewController.swift @@ -8,7 +8,7 @@ import Foundation -#if os(iOS) || os(tvOS) +#if os(iOS) || os(visionOS) || os(tvOS) import UIKit public typealias OAuthViewController = UIViewController #elseif os(watchOS) @@ -22,7 +22,7 @@ import Foundation /// Delegate for OAuthWebViewController public protocol OAuthWebViewControllerDelegate: AnyObject { - #if os(iOS) || os(tvOS) + #if os(iOS) || os(visionOS) || os(tvOS) /// Did web view presented (work only without navigation controller) func oauthWebViewControllerDidPresent() /// Did web view dismiss (work only without navigation controller) @@ -38,12 +38,12 @@ public protocol OAuthWebViewControllerDelegate: AnyObject { /// A web view controller, which handler OAuthSwift authentification. Must be override to display a web view. open class OAuthWebViewController: OAuthViewController, OAuthSwiftURLHandlerType { - #if os(iOS) || os(tvOS) || os(OSX) + #if os(iOS) || os(visionOS) || os(tvOS) || os(OSX) /// Delegate for this view public weak var delegate: OAuthWebViewControllerDelegate? #endif - #if os(iOS) || os(tvOS) + #if os(iOS) || os(visionOS) || os(tvOS) /// If controller have an navigation controller, application top view controller could be used if true public var useTopViewControlerInsteadOfNavigation = false @@ -85,7 +85,7 @@ open class OAuthWebViewController: OAuthViewController, OAuthSwiftURLHandlerType open func doHandle(_ url: URL) { OAuthSwift.log?.trace("OAuthWebViewController: present Safari view controller, url: \(url)") - #if os(iOS) || os(tvOS) + #if os(iOS) || os(visionOS) || os(tvOS) let completion: () -> Void = { [unowned self] in self.delegate?.oauthWebViewControllerDidPresent() } @@ -135,7 +135,7 @@ open class OAuthWebViewController: OAuthViewController, OAuthSwiftURLHandlerType open func dismissWebViewController() { OAuthSwift.log?.trace("OAuthWebViewController: dismiss view controller") - #if os(iOS) || os(tvOS) + #if os(iOS) || os(visionOS) || os(tvOS) let completion: () -> Void = { [weak self] in self?.delegate?.oauthWebViewControllerDidDismiss() } @@ -165,7 +165,7 @@ open class OAuthWebViewController: OAuthViewController, OAuthSwiftURLHandlerType } // MARK: overrides - #if os(iOS) || os(tvOS) + #if os(iOS) || os(visionOS) || os(tvOS) open override func viewWillAppear(_ animated: Bool) { self.delegate?.oauthWebViewControllerWillAppear() } diff --git a/Sources/OAuthSwiftHTTPRequest.swift b/Sources/OAuthSwiftHTTPRequest.swift index a4874b1..1790835 100644 --- a/Sources/OAuthSwiftHTTPRequest.swift +++ b/Sources/OAuthSwiftHTTPRequest.swift @@ -7,7 +7,7 @@ // import Foundation -#if os(iOS) +#if os(iOS) || os(visionOS) #if !OAUTH_APP_EXTENSIONS import UIKit #endif diff --git a/Sources/OAuthSwiftURLHandlerType.swift b/Sources/OAuthSwiftURLHandlerType.swift index f52bb65..0f7ab35 100644 --- a/Sources/OAuthSwiftURLHandlerType.swift +++ b/Sources/OAuthSwiftURLHandlerType.swift @@ -8,7 +8,7 @@ import Foundation -#if os(iOS) || os(tvOS) +#if os(iOS) || os(visionOS) || os(tvOS) import UIKit #elseif os(watchOS) import WatchKit diff --git a/Sources/UIApplication+OAuthSwift.swift b/Sources/UIApplication+OAuthSwift.swift index 07ab551..77f04fe 100644 --- a/Sources/UIApplication+OAuthSwift.swift +++ b/Sources/UIApplication+OAuthSwift.swift @@ -6,7 +6,7 @@ // Copyright © 2015 Dongri Jin. All rights reserved. // -#if os(iOS) || os(tvOS) +#if os(iOS) || os(visionOS) || os(tvOS) import UIKit extension UIApplication { @@ -30,11 +30,15 @@ } public var topWindow: UIWindow? { + #if os(iOS) || os(tvOS) if #available(iOS 13.0, tvOS 13.0, *) { return self.topWindowScene?.windows.first } else { return self.keyWindow } + #elseif os(visionOS) + return self.topWindowScene?.windows.first + #endif } var topViewController: UIViewController? {