我正在与Swift 3 and Xcode 8 (iOS 10.1)
合作,我对整个世界都是陌生的。 :)UIApplication.sharedApplication.open()不加载网址
我对外部应用程序进行身份验证以获取访问令牌。用例是:
1)从我的应用程序
2)加载外部应用程序验证用户并获得访问令牌
3)从外部应用程序
我重定向到我的应用程序我能做1)和2),但不能3)。外部应用程序已指定您配置一个重定向参数,我已经完成了。但是,唉,没有雪茄。
我已经为两个应用程序在Info.plist
中设置了URL方案。我没有在控制台或调试器中发现任何错误。
我过去4天一直在使用Google进行搜索,这是我迄今为止提出的解决方案。现在,我看到控制台消息,但外部应用程序不再开放。
的AppDelegate
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
if (url.scheme == "extapp") {
print("working with extapp scheme")
} else if (url.scheme == "myapp") {
print("redirecting back to app after working with extapp")
}
return true
}
的ViewController
@IBAction func loginButton(_ sender: Any) {
let id = text.text
let currentCharacterCount = id.text?.characters.count ?? 0
if currentCharacterCount == 0 {
self.showAlert(text: "Please provide a id.")
} else if currentCharacterCount < 10 {
self.showAlert(text: "Oh! id doesn't seem to be in the correct format. Try again.")
} else {
if (self.firebaseData.callAuth(loggedIn: id!)) {
OpenExtApp()
}
}
}
func OpenExtApp() {
let Url = URL(string: "extapp:///?autostart=\(token)&redirect=myapp://key")
if (UIApplication.shared.canOpenURL(Url!)) {
UIApplication.shared.open(Url!, options: [:])
}
}
我会很感激你以任何方式帮助。
是你在你的plist –
添加URL模式'extapp' @ Anbu.Karthik是的,我有,如前所述在我的问题。 – Mina
是否内部阻挡?,放置断点并检查一次。 –