【发布时间】:2021-07-20 16:41:33
【问题描述】:
我希望应用打开社交媒体应用(即 Facebook),但如果用户没有安装应用,我宁愿将他们重定向到应用的单独部分(webView,留在应用中) .我尝试了几种不同的方法并进行了一些研究,但还没有找到解决方案。这可能吗?如果我的代码不完美,我提前道歉!
if UIApplication.shared.canOpenURL(URL(string: "myLink")!) {
UIApplication.shared.open(URL(string: "myLink")!)
} else {
// If Facebook App is not installed, open WebView with Facebook Link
self.parent?.performSegue(withIdentifier: "myLink", sender: self)
}
【问题讨论】: