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

Viewed 15059

This is the code I use:

let instagramURL = NSURL(string: "instagram://app")
if UIApplication.shared.canOpenURL(instagramURL! as URL) {
  //Code
} else {
  //Showing message "Please install the Instagram application"
}

I am getting unsuccessful to enter in if loop.

I get this error:

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

I have also Login with Instagram in my device.

4 Answers

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:

enter image description here

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

enter image description here

Related