iOS canOpenURL返回true,但未安装应用程序(facebook) [英] iOS canOpenURL returns true, but app is not installed(facebook)

查看:321
本文介绍了iOS canOpenURL返回true,但未安装应用程序(facebook)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我想检查我的应用程序是否安装了Facebook App.

Currently, I want to check in my app whether Facebook App is installed or not.

我在做什么:

UIApplication.shared.canOpenURL(URL(string: "fb://")!)enter code here

在URL方案中,我添加了fb,所以也不要错过该部分.

In URL Schemes I have added fb, so not missed that part too.

但是canOpenURL返回TRUE!但是该应用程序未安装.我重新启动设备,没有帮助.为什么会这样呢? 更新:一些代码

But canOpenURL RETURNS TRUE ! But the app IS UNinstalled. I restarted the device, not helped. Why this is happening? UPDATE: some code

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如果未安装该应用程序

SOLUTION: I found the solution people. In URL types I had been added fb45....(id of my app), and also added fb, which one shouldn't be there, I removed fb, and only kept the one with id, so the openURL now returns false if the app is not installed

推荐答案

您需要将fb添加到应用程序plist中的LSApplicationQueriesSchemes数组中,而不是URL schemes数组中,如下所示:

You need to add fb to the LSApplicationQueriesSchemes array in the app plist, not the URL schemes array, like so:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fb</string>
</array>

这篇关于iOS canOpenURL返回true,但未安装应用程序(facebook)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆