This is the code I use:
let instagramURL = NSURL(string: \"instagram://app\")
if UIApplication.shared.canOpenURL(instagramURL! as URL) {
//Code
} else {
Open your plist as source code and paste following code:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>instagram</string>
</array>
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.
For those who try to open the app using custom URL Scheme (assume that app FirstApp opens SecondApp):
LSApplicationQueriesSchemes
with URL Scheme to Info.plist like this: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.