mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 19:53:25 +01:00
[AltStoreCore] Fixes signing-in to Patreon with Google account
This commit is contained in:
@@ -94,9 +94,12 @@ public extension PatreonAPI
|
|||||||
let configuration = WKWebViewConfiguration()
|
let configuration = WKWebViewConfiguration()
|
||||||
configuration.setURLSchemeHandler(self, forURLScheme: "altstore")
|
configuration.setURLSchemeHandler(self, forURLScheme: "altstore")
|
||||||
configuration.websiteDataStore = .default()
|
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)
|
let webViewController = WebViewController(url: requestURL, configuration: configuration)
|
||||||
webViewController.delegate = self
|
webViewController.delegate = self
|
||||||
|
webViewController.webView.uiDelegate = self
|
||||||
self.webViewController = webViewController
|
self.webViewController = webViewController
|
||||||
|
|
||||||
let callbackURL = try await withCheckedThrowingContinuation { continuation in
|
let callbackURL = try await withCheckedThrowingContinuation { continuation in
|
||||||
@@ -469,3 +472,25 @@ extension PatreonAPI: WKURLSchemeHandler
|
|||||||
Logger.main.debug("WKWebView stopped handling url scheme.")
|
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