【发布时间】:2018-07-26 16:54:35
【问题描述】:
我正在我的应用程序上创建一个类似 facebook 的按钮,并希望首先将它们重定向到实际应用程序。虽然,它一直在 Safari 中打开。我正在手机上测试,我有 facebook
我试过了
fb://profile/<id>
fb://page/<id>
fb://<id>
而且仍然每个请求都会重定向到 Safari。
我的部署目标是 9.0。
let appUrl : URL = URL(string: "fb://profile/{myId}")!
let webUrl : URL = URL(string: "https://www.facebook.com/{myFacebookUsername}")!
if UIApplication.shared.canOpenURL(appUrl) {
UIApplication.shared.openURL(appUrl)
print("in app")
} else {
UIApplication.shared.openURL(webUrl)
print("webbb")
}
【问题讨论】: