2015-12-30 16 views
1

您可能認爲這是一個重複的問題,但事實並非如此,我完全瞭解所有關於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!) 

我不明白爲什麼!

回答

0

我找到了解決我自己的問題。我在這裏回答它,而不是刪除我的問題,因爲它可能有助於某個人。

這裏的問題是,我試圖爲其他開發人員開發一個框架,我有一個測試應用程序,我正在使用它來檢查一切是否正常與我的框架。我在框架目標中設置了LSApplicationQueriesSchemes值,而不是實際的測試應用程序。 SO:

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

相關問題