This app is not allowed to query for scheme XYZ://

三世轮回 提交于 2019-12-02 12:33:05

问题


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:

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>

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

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

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


}

It always returns

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

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

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

I can't figure it out why!


回答1:


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.

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:

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



来源:https://stackoverflow.com/questions/34523816/this-app-is-not-allowed-to-query-for-scheme-xyz

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!