Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
411 views
in Technique[技术] by (71.8m points)

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

Im trying to add the Instagram url to my app in iOS9 however I am getting the following warning:

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

However, Ive added the following to the LSApplicationQueriesSchemes in my info.plist;

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>instagram</string>
    <string>instagram://media?id=MEDIA_ID</string>//this one seems to be the issue
</array>

Any help is greatly appreciated?

EDIT 1

This is the code I am using to open 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");
}

based off this example.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. Your LSApplicationQueriesSchemes entry should only have schemes. There's no point to the second entry.

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>instagram</string>
    </array>
    
  2. Read the error. You are trying to open the URL with a typo in the scheme. Fix your reference to instragram in your call to canOpenURL:.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...