此应用不允许查询方案XYZ://

问题描述:

您可能认为这是一个重复的问题,但事实并非如此,我完全了解所有关于canOpenURL及其iOS9注意事项的答案,但这里是我的问题:此应用不允许查询方案XYZ://

我试图检查一个特定的应用程序是否安装在我的设备上(都由我开发)。 我已经宣布计划在AppA为:

<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我在info.plist中说:现在

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

,在AppB我试图找出如果我已经安装了这样的AppA

 internal static let appAScheme = "XYZ://" 

static func AppAInstalled() -> Bool { 

    let appAURL = NSURL(string: appAScheme) 

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


} 

它总是返回

-canOpenURL: failed for URL: "XYZ://" - error: "This app is not allowed to query for scheme XYZ"

如何,如果我试图从AppB开放AppA它将工作没有问题!

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

我不明白为什么!

我找到了解决我自己的问题。我在这里回答它,而不是删除我的问题,因为它可能有助于某个人。

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

You need to set the whitelist values in your app target's info.plist