简体   繁体   中英

iOS canOpenURL returns true, but app is not installed(facebook)

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

What am I doing:

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

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

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")!)
}

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM