向LSApplicationQueriesSchemes添加了方案,但是canOpenURL仍然失败

问题描述 投票:1回答:1

请帮助!尽管在LSApplicationQueriesSchemes中包含了方案,但为什么我仍不被允许查询方案?

我的班级:

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)
            }


}

我的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>

“错误消息”

2019-12-17 15:58:08.426142 + 0800 drmorpheus [1000:203271] -canOpenURL:网址失败:“ youtube://”-错误:“此应用不允许查询方案youtube“下载应用]

updated code

ios swift
1个回答
0
投票

您已经编辑了属于UI测试目标而非应用目标的info.plist。将LSApplicationQueriesSchemes条目添加到应用程序的info.plist中。

© www.soinside.com 2019 - 2024. All rights reserved.