如果钱包中没有卡,Apple Pay 按钮的行为更可取?

What behaviour is pereferable for Apple Pay button if no cards in the wallet?

我查看了 apple 指南,但没有找到任何关于这个问题的信息。

附加信息:

我已将 Apple Pay 按钮添加到应用程序,如果没有可用于支付的功能(例如卡),则将其隐藏。但是客户不喜欢它并想要 一些其他 方法。我认为我们可能会像要求用户添加卡一样打开钱包,但我不确定 Apple 指南对此有何看法。

有明确的推荐吗?

这是 Apple 的 guidelines on implementing Apple Pay.

相关部分如下: 使用 PKPaymentAuthorizationViewController 方法

If canMakePayments returns NO, the device does not support Apple Pay. Do not display the Apple Pay button. Instead, fall back to another method of payment.

If canMakePayments returns YES but canMakePaymentsUsingNetworks: returns NO, the device supports Apple Pay, but the user has not added a card for any of the requested networks. You can, optionally, display a payment setup button, prompting the user to set up his or her card. As soon as the user taps this button, initiate the process of setting up a new card (for example, by calling the openPaymentSetup method).

To create an Apple Pay–branded button for initiating payment request on iOS 8.3 or later, use the PKPaymentButton class.

来自 PKPaymentButton 文档:

Provides a button that is used either to trigger payments through Apple Pay or to prompt the user to set up a card.

您可以使用 setUp 类型对其进行初始化。

当用户点击这个按钮时,调用openPaymentSetup

 override func viewDidLoad() {
    super.viewDidLoad()

    var applePayButton: PKPaymentButton?
    if !PKPaymentAuthorizationViewController.canMakePayments() {
      // Apple Pay not supported
      return
    }
    if !PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [.masterCard]) {
      // Apple Pay supported and payment not setup
      applePayButton = PKPaymentButton.init(paymentButtonType: .setUp, paymentButtonStyle: .black)
      applePayButton?.addTarget(self, action: #selector(self.setupPressed(_:)), for: .touchUpInside)
    } else {
      // Apple Pay supported and payment setup
      applePayButton = PKPaymentButton.init(paymentButtonType: .buy, paymentButtonStyle: .black)
      applePayButton?.addTarget(self, action: #selector(self.payPressed(_:)), for: .touchUpInside)
    }

    applePayButton?.translatesAutoresizingMaskIntoConstraints = false
    self.view.addSubview(applePayButton!)
    applePayButton?.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
    applePayButton?.widthAnchor.constraint(equalToConstant: 200).isActive = true
    applePayButton?.heightAnchor.constraint(equalToConstant: 60).isActive = true
    applePayButton?.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: -20).isActive = true

  }

  @objc func payPressed(_ sender: PKPaymentButton){
    // Start payment
  }

  @objc func setupPressed(_ sender: PKPaymentButton){
    let passLibrary = PKPassLibrary()
    passLibrary.openPaymentSetup()
  }

}