Krunal Patel Krunal Patel -4 years ago 132
Swift Question

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

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.

Answer Source

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

Please add this LSApplicationQueriesSchemes and add instagram://app in your info.plist and it will work. enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download