【问题标题】:canOpenUrl - This app is not allowed to query for scheme instragramcanOpenUrl - 此应用不允许查询方案 instagram
【发布时间】:2015-12-28 11:50:12
【问题描述】:

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

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

但是,我在info.plistLSApplicationQueriesSchemes 中添加了以下内容;

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

基于此示例。

【问题讨论】:

  • 是不是因为你写的是instragram而不是instagram?
  • @JamesP 打自己的脸我怎么错过了,但我已经修复了它,问题仍然存在。

标签: ios info-plist


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

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>instagram</string>
    </array>
    
  2. 读取错误。您正在尝试打开方案中存在拼写错误的 URL。修正您对canOpenURL: 的调用中对instragram 的引用。

【讨论】:

  • 这很尴尬,我读了大约 30 次错误信息并一直在看它。错误现在消失了。第一点也是正确的,不需要第二项。
  • 这就像尝试校对自己的论文。它不起作用。你总是看到你期望它是什么,而不是它真正的样子。
【解决方案2】:

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

【讨论】:

  • 这与问题无关。
  • 这并没有回答真正的问题
  • facebook 拥有 instgram.. 咳
【解决方案3】:

只输入&lt;string&gt;instagram&lt;/string&gt;。不需要完整路径,而是方案 url 的基础。

【讨论】:

    猜你喜欢
    • 2023-01-13
    • 1970-01-01
    • 2016-04-04
    • 1970-01-01
    • 2015-12-19
    • 1970-01-01
    • 1970-01-01
    • 2015-12-20
    • 2019-01-28
    相关资源
    最近更新 更多