Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS canOpenURL返回true,但未安装应用程序(facebook)_Ios_Swift_Facebook_Url - Fatal编程技术网

iOS canOpenURL返回true,但未安装应用程序(facebook)

iOS canOpenURL返回true,但未安装应用程序(facebook),ios,swift,facebook,url,Ios,Swift,Facebook,Url,目前,我想在我的应用程序中检查是否安装了Facebook应用程序 我在做什么: UIApplication.shared.canOpenURL(URL(string: "fb://")!)enter code here 在URL方案中,我添加了fb,所以也不要错过这一部分 但是canOpenURL返回TRUE!但该应用程序已被卸载。我重新启动了设备,但没有帮助。为什么会这样? 更新:一些代码 if UIApplication.shared.canOpenURL(URL(string: "fb:

目前,我想在我的应用程序中检查是否安装了Facebook应用程序

我在做什么:

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为的fb,因此如果应用程序未安装,openURL现在返回false

您需要将
fb
添加到应用程序列表中的
LSApplicationQueriesSchemes
数组中,不是
URL方案
数组,如下所示:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fb</string>
</array>
LSApplicationQueriesSchemes
食品饮料

如果您将此添加到url schemes应用程序可以打开,您还想让它做什么?我想在未安装Facebook应用程序时处理此情况,但每次我都会得到正确答案,即使应用程序被卸载,卸载应用程序后会发生什么?一切都很顺利。它正在尝试与Facebook共享,但应用程序已卸载,但我需要将用户重定向到应用程序商店。你救了我的命