![](/img/trans.png)
[英]canOpenURL return true and app is installed but app is not opening
[英]iOS canOpenURL returns true, but app is not installed(facebook)
目前,我想检查我的应用程序是否已安装Facebook App。
我在做什么:
UIApplication.shared.canOpenURL(URL(string: "fb://")!)enter code here
在URL方案中,我添加了fb,所以也不要错过该部分。
但是canOpenURL返回TRUE
! 但是该应用程序未安装。 我重新启动设备,没有帮助。 为什么会这样呢? 更新:一些代码
if UIApplication.shared.canOpenURL(URL(string: "fb://")!) {
self.shareToFacebook(with: completion)
} else {
progressVC.dismiss(animated: false, completion: nil)
UIApplication.shared.open(URL(string: "https://itunes.apple.com/us/app/facebook/id284882215")!)
}
解决方案:我找到了解决方案的人。 在URL类型中,我已经添加了fb45 ....(我的应用程序的ID),还添加了fb,这个不应该在那里,我删除了fb,只保留了ID,所以openURL现在返回false如果未安装该应用程序
您需要将fb
添加到应用程序plist中的LSApplicationQueriesSchemes
数组中,而不是URL schemes
数组中,如下所示:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fb</string>
</array>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.