how to call the apple wallet from ios app using swift

前端 未结 1 1123
半阙折子戏
半阙折子戏 2021-01-07 09:10

I want to display apple wallet add cards page whenever user clicks the add cards to wallet button in my ios app. how to call the apple wallet from ios app. I enabled wallet

相关标签:
1条回答
  • 2021-01-07 09:41

    NOTE: This is for Card Issuers only. If you want to redirect a user to add a payment method, use the openPaymentSetup method. See my answer here for more details.

    For Card Issuers, you need a special entitlement issued by Apple.

    Your app must include this entitlement before you can use this class. For more information on requesting this entitlement, see the Card Issuers section at developer.apple.com/apple-pay/.

    From this answer:

    PKAddPaymentPassViewController requires the com.apple.developer.payment-pass-provisioning entitlement key for your app. The bad news is that not anyone can submit apps with this entitlement as it requires special permission from Apple, which I believe is reserved for card issuers like banks and similar. If you believe that you qualify you need to contact Apple directly at apple-pay-inquiries@apple.com

    You need to implement the delegate methods, and initialise it with a configuration.

    import UIKit
    import PassKit
    
    class ViewController: UIViewController, PKAddPaymentPassViewControllerDelegate {
    
      override func viewDidLoad() {
        super.viewDidLoad()
        if (!PKAddPaymentPassViewController.canAddPaymentPass()){
          // use other payment method / alert user
        }
        let config = PKAddPaymentPassRequestConfiguration.init(encryptionScheme: PKEncryptionScheme.ECC_V2)
        let addPaymentPassVC = PKAddPaymentPassViewController.init(requestConfiguration: config!, delegate: self)
        self.present(addPaymentPassVC!, animated: true, completion: nil)
      }
    
      func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, generateRequestWithCertificateChain certificates: [Data], nonce: Data, nonceSignature: Data, completionHandler handler: @escaping (PKAddPaymentPassRequest) -> Void) {
    
      }
    
      func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, didFinishAdding pass: PKPaymentPass?, error: Error?) {
        // pass added
      }
    
    }
    
    0 讨论(0)
提交回复
热议问题