mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[AltStoreCore] Fixes signing-in to Patreon with Google account
This commit is contained in:
@@ -97,9 +97,12 @@ public extension PatreonAPI
|
||||
let configuration = WKWebViewConfiguration()
|
||||
configuration.setURLSchemeHandler(self, forURLScheme: "altstore")
|
||||
configuration.websiteDataStore = .default()
|
||||
configuration.preferences.javaScriptCanOpenWindowsAutomatically = true
|
||||
configuration.applicationNameForUserAgent = "Version/17.1.2 Mobile/15E148 Safari/604.1" // Required for "Sign-in With Google" to work in WKWebView
|
||||
|
||||
let webViewController = WebViewController(url: requestURL, configuration: configuration)
|
||||
webViewController.delegate = self
|
||||
webViewController.webView.uiDelegate = self
|
||||
self.webViewController = webViewController
|
||||
|
||||
let callbackURL = try await withCheckedThrowingContinuation { continuation in
|
||||
@@ -479,3 +482,25 @@ extension PatreonAPI: WKURLSchemeHandler
|
||||
Logger.main.debug("WKWebView stopped handling url scheme.")
|
||||
}
|
||||
}
|
||||
|
||||
extension PatreonAPI: WKUIDelegate
|
||||
{
|
||||
public func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView?
|
||||
{
|
||||
// Signing in with Google requires us to use separate windows/"tabs"
|
||||
|
||||
Logger.main.debug("Intercepting new window request: \(navigationAction.request)")
|
||||
|
||||
let webViewController = WebViewController(request: navigationAction.request, configuration: configuration)
|
||||
webViewController.delegate = self
|
||||
webViewController.webView.uiDelegate = self
|
||||
self.webViewController?.navigationController?.pushViewController(webViewController, animated: true)
|
||||
|
||||
return webViewController.webView
|
||||
}
|
||||
|
||||
public func webViewDidClose(_ webView: WKWebView)
|
||||
{
|
||||
self.webViewController?.navigationController?.popToRootViewController(animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user