canOpenUrl - 不允许此应用程序查询 scheme instagram

canOpenUrl - This app is not allowed to query for scheme instragram

我试图在 iOS9 中将 Instagram url 添加到我的应用程序,但是我收到以下警告:

-canOpenURL: failed for URL: "instragram://media?id=MEDIA_ID" - error: "This app is not allowed to query for scheme instragram"

但是,我在 info.plist;

中的 LSApplicationQueriesSchemes 添加了以下内容
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>instagram</string>
    <string>instagram://media?id=MEDIA_ID</string>//this one seems to be the issue
</array>

非常感谢任何帮助?

编辑 1

这是我用来打开 Instagram 的代码:

 NSURL * instagramURL = [NSURL URLWithString:@"instragram://media?id=MEDIA_ID"];//edit: note, to anyone copy pasting this code, please notice the typo OP has in the url, that being "instragram" instead of "instagram". This typo was discovered after this Whosebug question was posted.
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
    //do stuff
}
else{
    NSLog(@"NO instgram found");
}

基于此示例。

  1. 您的 LSApplicationQueriesSchemes 条目应该只有方案。第二个条目没有意义。

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>instagram</string>
    </array>
    
  2. 读取错误。您正试图打开 URL,但方案中有拼写错误。在调用 canOpenURL:.

  3. 时修复对 instragram 的引用

只放<string>instagram</string>。不需要完整路径,而是方案的基础 url。

需要Facebook的人:

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbauth</string>
        <string>fbauth2</string>
        <string>fb-messenger-api20140430</string>
        <string>fbapi20130214</string>
        <string>fbapi20130410</string>
        <string>fbapi20130702</string>
        <string>fbapi20131010</string>
        <string>fbapi20131219</string>
        <string>fbapi20140410</string>
        <string>fbapi20140116</string>
        <string>fbapi20150313</string>
        <string>fbapi20150629</string>
        <string>fbshareextension</string>
    </array>