我正在使用带有 UIWebView 的 UIViewController。在此 UIWebView 中,用户必须登录,成功登录后,应将用户重定向回应用程序。但就我而言,它保留在 UIWebView 中并且不会将我重定向回应用程序。
我尝试在 API Delegate 中使用此代码:
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
DispatchQueue.main.async {
if (url.scheme == "go-back"){
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "WebView") as! ViewController
self.window?.rootViewController!.present(controller, animated: true, completion: { () -> Void in
})
}
}
return true
}
Run Code Online (Sandbox Code Playgroud)
并创建了一个 URL 方案,但它不起作用。