Skip to content

Commit

Permalink
Add check on tvOS version too #591
Browse files Browse the repository at this point in the history
  • Loading branch information
phimage authored and e-marchand committed Apr 30, 2020
1 parent 3430e76 commit 0a5d252
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Demo/Common/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ extension ViewController {
return OAuthSwiftOpenURLExternally.sharedInstance
case .asWeb:
#if os(iOS)
if #available(iOS 13.0, *) {
if #available(iOS 13.0, tvOS 13.0, *) {
return ASWebAuthenticationURLHandler(callbackUrlScheme: "oauth-swift://oauth-callback/", presentationContextProvider: self)
}
#endif
Expand Down Expand Up @@ -1678,7 +1678,7 @@ import SafariServices
#if canImport(AuthenticationServices)
import AuthenticationServices
#endif
@available(iOS 13.0, macCatalyst 13.0, *)
@available(iOS 13.0, tvOS 13.0, macCatalyst 13.0, *)
extension ViewController: ASWebAuthenticationPresentationContextProviding {
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
return UIApplication.shared.topWindow ?? ASPresentationAnchor()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Handler/ASWebAuthenticationURLHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import SafariServices
import AuthenticationServices
#endif

@available(iOS 13.0, macCatalyst 13.0, *)
@available(iOS 13.0, tvOS 13.0, macCatalyst 13.0, *)
open class ASWebAuthenticationURLHandler: OAuthSwiftURLHandlerType {
var webAuthSession: ASWebAuthenticationSession!
let prefersEphemeralWebBrowserSession: Bool
Expand Down
2 changes: 1 addition & 1 deletion Sources/Handler/OAuthSwiftOpenURLExternally.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ open class OAuthSwiftOpenURLExternally: OAuthSwiftURLHandlerType {
@objc open func handle(_ url: URL) {
#if os(iOS) || os(tvOS)
#if !OAUTH_APP_EXTENSIONS
if #available(iOS 10.0, *) {
if #available(iOS 10.0, tvOS 10.0, *) {
UIApplication.shared.open(url)
} else {
UIApplication.shared.openURL(url)
Expand Down
2 changes: 1 addition & 1 deletion Sources/String+OAuthSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extension String {
let scanner = Scanner(string: string)

while !scanner.isAtEnd {
if #available(iOS 13.0, OSX 10.15, watchOS 6.0, *) {
if #available(iOS 13.0, tvOS 13.0, OSX 10.15, watchOS 6.0, *) {
let key = scanner.scanUpToString(keyValueSeparator)
_ = scanner.scanString(keyValueSeparator)

Expand Down
6 changes: 3 additions & 3 deletions Sources/UIApplication+OAuthSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
#endif
}

@available(iOS 13.0, *)
@available(iOS 13.0, tvOS 13.0, *)
public var connectedWindowScenes: [UIWindowScene] {
return self.connectedScenes.compactMap { $0 as? UIWindowScene }
}

@available(iOS 13.0, *)
@available(iOS 13.0, tvOS 13.0, *)
public var topWindowScene: UIWindowScene? {
let scenes = connectedWindowScenes
return scenes.filter { $0.activationState == .foregroundActive }.first ?? scenes.first
}

public var topWindow: UIWindow? {
if #available(iOS 13.0, *) {
if #available(iOS 13.0, tvOS 13.0, *) {
return self.topWindowScene?.windows.first
} else {
return self.keyWindow
Expand Down

0 comments on commit 0a5d252

Please sign in to comment.