canOpenUrl - 此应用程序不允许查询方案instragram

时间:2015-09-30 15:44:47

标签: ios instagram ios9 info-plist

我试图在iOS9中将Instagram网址添加到我的应用中但是我收到以下警告:

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

但是,我已将以下内容添加到LSApplicationQueriesSchemes;

中的info.plist
<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 StackOverflow question was posted.
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
    //do stuff
}
else{
    NSLog(@"NO instgram found");
}

基于这个例子。

3 个答案:

答案 0 :(得分:165)

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

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>instagram</string>
    </array>
    
  2. 阅读错误。您正尝试在方案中使用拼写错误打开URL。在通话instragram

  3. 中修复对canOpenURL:的引用

答案 1 :(得分:5)

只放<string>instagram</string>。它不是完整路径,而是方案网址的基础。

答案 2 :(得分:4)

对于需要的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>