Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Added scheme to LSApplicationQueriesSchemes but canOpenURL still fails

Tags:

ios

swift

Please help! Why am i still getting not allowed to query for scheme despite including the scheme in the LSApplicationQueriesSchemes?

My class:

class LearningBotScreen: UIViewController {

    @IBAction func googleAssistantOpenButtonPressed(_ sender: Any) {
        let googleAssistantUrl = URL(string:"youtube://")!

        if UIApplication.shared.canOpenURL(googleAssistantUrl){
            print("opening");
            UIApplication.shared.open(googleAssistantUrl)
            /*UIApplication.shared.open(googleAssistantUrl!, options:[:], completionHandler: nil)*/
        }
        else{
            print("download app")
            UIApplication.shared.open(URL(string: "http://apps.apple.com/sg/app/id1220976145")!, options: [:], completionHandler: nil)
            }


}

My info.plist:

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0">
    <dict>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>instagram</string>
        <string>youtube</string>
    </array>
    <key>LSApplicationCategoryType</key>    <string></string>    
    <key>CFBundleExecutable</key>   <string>$(EXECUTABLE_NAME)</string>      
    <key>CFBundleIdentifier</key>   <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>    
    <key>CFBundleInfoDictionaryVersion</key>    <string>6.0</string>     
    <key>CFBundleName</key>     <string>$(PRODUCT_NAME)</string>     
    <key>CFBundlePackageType</key>  <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>      
    <key>CFBundleShortVersionString</key>   <string>1.0</string>     
    <key>CFBundleVersion</key>  <string>1</string> </dict> </plist>

The error message

2019-12-17 15:58:08.426142+0800 drmorpheus[1000:203271] -canOpenURL: failed for URL: "youtube://" - error: "This app is not allowed to query for scheme youtube" download app

updated code

like image 847
Melissa Lim Avatar asked Dec 05 '25 21:12

Melissa Lim


1 Answers

You've edited the info.plist that belongs to your UI tests target, not your app target. Add the LSApplicationQueriesSchemes entry to your app's info.plist instead.

like image 137
TylerP Avatar answered Dec 07 '25 12:12

TylerP