0
votes

Searching Apple Pay / Passkit / Wallet documentation, I've found very few code examples and pretty poor documentation. We're attempting to present a payment pass we've provisioned rather than just launch the wallet with openPaymentSetup().

According to PKPassLibrary docs, this can be achieved with PKPassLibrary.present(). We're invoking this function and it launches Apple Pay directly into the add a card wizard, which seems worse than the UX from openPaymentSetup().

The code we're using is:

    let library: PKPassLibrary = PKPassLibrary()
    let passes: [PKPass] = library.remotePaymentPasses()
    if !passes.isEmpty, #available(iOS 10.0, *) {
        library.present(passes[passes.count-1].paymentPass!)
    } else {
        library.openPaymentSetup()
    }

We get the pass library and our passes, then conditionally attempt to present the last pass.

Does anyone know how to show a pass rather than launching a tutorial or add a card wizard?

1
Does your app have the appropriate entitlement to see the pass you are presenting?Paulw11
How do you know that the pass you provisioned is the last in the array of passes? You might want to filter or iterate over the passes to find those with passTypeIdentifier matching your type.Mike Taverne
The passes returned are payment passes we've provisioned into Apple Pay, so yeah, we have entitlement. I don't know that the pass I want to show is last. This is rudimentary code to try and get it working. The problem we're trying to solve is showing any pass. As stated, openPaymentSetup() launches a tutorial and present() launches to add a card -- even though we just provisioned and added the pass (card).user9737686

1 Answers

0
votes

You can still use presentPaymentPass api to present a PaymentPass. But your iOS version should be >=10.3.3 even if Apple Documentation says iOS version > 10.0. This is a wrong documentation from Apple.