Ios 如何通过代码检查iPhone上是否安装了PayPal应用程序?

Ios 如何通过代码检查iPhone上是否安装了PayPal应用程序?,ios,swift,paypal,Ios,Swift,Paypal,以下是我检查微信应用程序是否已安装的方式: static func isWechatAvailable() -> Bool { if let url = NSURL(string:"weixin://scanqrcode")?.absoluteURL, UIApplication.shared.canOpenURL(url) { return true } return false } 我如何为贝宝做到这一点?PayPal似乎没有该方案的url。安

以下是我检查微信应用程序是否已安装的方式:

static func isWechatAvailable() -> Bool {
    if let url = NSURL(string:"weixin://scanqrcode")?.absoluteURL, UIApplication.shared.canOpenURL(url) {
        return true
    }
    return false
}
我如何为贝宝做到这一点?PayPal似乎没有该方案的url。安装和使用PayPal SDK需要大量的工作。有什么建议吗


谢谢

您应该使用https://URL方案按原样打开该URL。这样URL将在Safari中打开


paypal://
URL方案仅适用于某些有限的paypal使用

首先,您需要在plist文件中提供一个lsapplicationqueryschemes条目,声明它试图查询哪些方案。在你的情况下,它是PayPal应用程序

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>paypal</string>
</array>
如果该设备安装了PayPal应用程序,您将得到真实的结果。如果您想查看其他应用程序,请将paypal替换为其他应用程序名称。

这可能很有用:
static func isPayPalAvailable() -> Bool {
    if let url = NSURL(string:"paypal:")?.absoluteURL, UIApplication.shared.canOpenURL(url) {
        return true
    }
    return false
}