CanOpenURL: failed URL: "instagram: // app" - error: "This application is not allowed to request for instagram schema"

This is the code I'm using:

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

I am unable to enter the if loop.

I get this error:

canOpenURL: crash for URL: "instagram: // app" - error: "This application is not allowed to request for a schema scheme"

I also have Instagram login on my device.

+7
ios iphone swift
source share
3 answers

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

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

Note. . One thing you should keep in mind is that it will not work on the simulator. For this you need a real device.

+14
source share

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

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

+4
source share

Open your plist as source code and paste the following code:

 <key>LSApplicationQueriesSchemes</key> <array> <string>instagram</string> </array> 
+3
source share

All Articles