![](/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.