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

标签 ios swift

请帮忙!为什么尽管将方案包含在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

最佳答案

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

关于ios - 向LSApplicationQueriesSchemes添加了方案,但是canOpenURL仍然失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59370075/

相关文章:

ios - 如何构建我的应用商店应用网址?

ios - 在 MVVM 应用程序中访问核心数据堆栈

ios - 将 iOS 应用程序组迁移到另一个开发者帐户

swift - bar Items 中的导航链接返回到 NavigationView 的顶部

ios - Firebase 检索数据 - 无法转换值(value)

ios - 在 self 解雇​​期间,弱者、强者或无主都不会做?

ios - 如何为 UIButtonTypeCustom 实现 tintcolor 行为

ios - 在 Travis CI 上,iOS 应用程序代码如何签名并上传到 Apple TestFlight?

ios - 如何在 PDFView 中选择连续文本以便添加注释?

swift - 使用 `Self` 作为参数的方法键入删除