如何验证ios设备是否支持Apple Pay [英] How to verify ios device supports Apple Pay

查看:346
本文介绍了如何验证ios设备是否支持Apple Pay的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在启动Apple Pay集成项目,并且能够在设备上连接交易,并使用Stripe授权付款。我实际上正在努力的部分是设备测试Apple Pay是否受支持的正确方法?因此,对于较旧的Iphone型号,我会选择隐藏Apple Pay功能,即使它们安装了ios8或ios9。

I'm starting an Apple Pay integration project and have been able to wire up a transaction on the device, and use Stripe to authorize the payment. The part I'm actually struggling with is the proper way for the device to test whether Apple Pay is supported? Thus, for older Iphone models I would choose to hide the Apple Pay features, even if they have ios8 or ios9 installed.

我可以检查设备型号,忽略申请支付< IPhone 5S。然而,如果我还需要开始测试IPad版本等,这会变得复杂。

I can probably check for the device model, and ignore Apply Pay for < Iphone5S. However this gets complicated if I also need to start testing IPad versions, etc.

我想知道是否有一种方法可以测试ApplePay是否受支持?

I was wondering if there is a single method somehow to test if ApplePay is supported?

我在网上发现这种方法是一个想法,但它声称苹果支付在Iphone5模拟器中得到支持,我想这并不完全正确。不幸的是,我没有Iphone5实际设备进行测试。

I found this method online as one idea, however it claimed apple pay was supported in the Iphone5 simulator, which I imagine is not entirely true. I do not have an Iphone5 actual device to test with unfortunately.

- (BOOL) applePaySupported {
    return [PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkVisa, PKPaymentNetworkMasterCard]];
}

编辑/解决方案:

我现在使用这一行,它被验证适用于Iphone5(不支持)和Iphone6(支持);我推测其他设备。我不完全确定它总是在模拟器中工作,但ApplePay在那里有点奇怪,测试最好在设备上完成。

I now use this line and it is verified to work for Iphone5 (not supported) vs Iphone6 (supported); and I presume other devices. I'm not entirely sure it always works in Simulator but ApplePay is a little odd in there anyway and testing is best done on device.

- (BOOL) applePaySupported {
    return [PKPaymentAuthorizationViewController canMakePayments] && [PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkVisa, PKPaymentNetworkMasterCard]];
}


推荐答案

canMakePayments - 无论卡配置如何,都会返回YES(True / 1)。

canMakePayments - Will return "YES" ( True / 1 ) irrespective of card configuration.

canMakePaymentsUsingNetworks - 如果卡未配置或未正确配置,将返回NO。

canMakePaymentsUsingNetworks - Will return "NO" , if card NOT configured or NOT configured properly.

因此,应检查两者...如果两者都应为TRUE则只需要使按钮Apple Pay可见。

So,should check both... If both should be TRUE then only need to make Button "Apple Pay" visible.

希望这有帮助。

这篇关于如何验证ios设备是否支持Apple Pay的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆