canOpenURL: failed for URL: “instagram://app” - error: “This app is not allowed to query for scheme instagram”

后端 未结 4 782
失恋的感觉
失恋的感觉 2021-01-01 12:12

This is the code I use:

let instagramURL = NSURL(string: \"instagram://app\")
if UIApplication.shared.canOpenURL(instagramURL! as URL) {
  //Code
} else {
           


        
相关标签:
4条回答
  • 2021-01-01 12:25

    Open your plist as source code and paste following code:

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>instagram</string>
    </array>
    
    0 讨论(0)
  • 2021-01-01 12:30

    Right click on your plist file and open it as source code. Then copy and paste below code:

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

    Note: One thing you have to keep in mind that it will not work on simulator. You need a real device for this.

    0 讨论(0)
  • 2021-01-01 12:38

    For those who try to open the app using custom URL Scheme (assume that app FirstApp opens SecondApp):

    • In FirstApp add LSApplicationQueriesSchemes with URL Scheme to Info.plist like this:

    • In SecondApp register new URL Scheme in URL Types like this:

    0 讨论(0)
  • 2021-01-01 12:42

    The issue is that you are not registering the URL scheme in the info.plist file.

    Please add this LSApplicationQueriesSchemes and add instagram in your info.plist and it will work.

    0 讨论(0)
提交回复
热议问题