canOpenURL: failed for URL: "instagram://app" - error: "(null)

canOpenURL: failed for URL: "instagram://app" - error: "(null)

我收到此错误:

-canOpenURL:URL 失败:"instagram://app" - 错误:“(null)”

这是我使用的代码:

let instagramURL = NSURL(string: "instagram://app")!     
if (UIApplication.sharedApplication().canOpenURL(instagramURL)) {
    //some code
}

我将 LSApplicationQueriesSchemes 添加到我的 info.plist 文件

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>instagram</string>
</array>

而且似乎 "recognise" instagram 方案,因为当我使用其他类似 "instagraam" 的东西时,我收到不同的错误消息(这是有道理的):

-canOpenURL:URL 失败:"instagraam://app" - 错误:"This app is not allowed to query for scheme instagraam"

我是不是遗漏了什么明显的东西?

正如评论中指出的那样 - 这实际上是 this 的副本。

在真实设备上它可以工作,只是模拟器的奇怪输出。