不允许该应用查询方案XYZ

不允许该应用查询方案XYZ

本文介绍了不允许该应用查询方案XYZ://的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可能会认为这是一个重复的问题,但并非如此,我完全知道关于 canOpenURL 及其在iOS 9上的注意事项的所有答案,但是这是我的问题:

You might think it's a duplicate question, but it's not, I'm totally aware of all the answers on SO about the canOpenURL and its caveats on iOS 9, but here is my problem:

我正在尝试检查设备上是否安装了特定的应用程序(均由我开发)。
我已经在 AppA 上宣布了该计划,因为:

I'm trying to check if an specific app is installed on my device (both developed by me).I have declared the scheme on AppA as:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>com.my.company.id</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>XYZ</string>
        </array>
    </dict>
</array>

,在另一个应用程序上, AppB I已在info.plist中添加:

and on the other app, AppB I have added in info.plist:

<key>LSApplicationQueriesSchemes</key>
<array>
 <string>XYZ</string>
</array>

现在,在 AppB 中找出我是否安装了 AppA

Now, in AppB I'm trying to find out if I have AppA installed like this:

     internal static let appAScheme = "XYZ://"

 static func  AppAInstalled() -> Bool {

    let appAURL = NSURL(string: appAScheme)

    return UIApplication.sharedApplication().canOpenURL(appAURL!)


}

它总是返回

但是,如果我尝试从 AppB 打开 AppA

How ever, If I try to open AppA from AppB it'll work with no problem!

// Works alright
UIApplication.sharedApplication().openURL(appAURL!)

我不知道为什么!

推荐答案

我已经找到了解决自己问题的方法。我在这里回答问题,而不仅仅是删除我的问题,因为它有一天可能对某人有所帮助。

I have found the solution to my own question. I'm answering it here instead of just deleting my question because it might help somebody someday.

这里的问题是我正在尝试为其他开发人员开发框架,我有一个测试应用程序,用于检查框架是否一切正常。我在框架目标而不是实际测试应用程序中设置了 LSApplicationQueriesSchemes 值。因此:

The problem here was that I'm trying to develop a framework for other developers, I have a test app that I'm using to check if everything is fine with my framework. I was setting LSApplicationQueriesSchemes values inside the framework target, not the actual test app. SO:

这篇关于不允许该应用查询方案XYZ://的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 10:48