Fixes Patreon login screen not appearing on iOS 13

This commit is contained in:
Riley Testut
2019-10-17 14:52:13 -07:00
parent ac8c6567db
commit 3bb3fba017

View File

@@ -71,7 +71,7 @@ extension PatreonAPI
}
}
class PatreonAPI
class PatreonAPI: NSObject
{
static let shared = PatreonAPI()
@@ -84,8 +84,9 @@ class PatreonAPI
private let session = URLSession(configuration: .ephemeral)
private let baseURL = URL(string: "https://www.patreon.com/")!
private init()
private override init()
{
super.init()
}
}
@@ -129,6 +130,11 @@ extension PatreonAPI
}
}
if #available(iOS 13.0, *)
{
self.authenticationSession?.presentationContextProvider = self
}
self.authenticationSession?.start()
}
@@ -384,3 +390,12 @@ private extension PatreonAPI
task.resume()
}
}
@available(iOS 13.0, *)
extension PatreonAPI: ASWebAuthenticationPresentationContextProviding
{
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor
{
return UIApplication.shared.keyWindow ?? UIWindow()
}
}