2

I am implementing in-app provisioning in my Xamarin.iOS app but an unable to get a correct response from the pkPassLibrary.CanAddPaymentPass method.

This is what tells your app if a customer has already added their card to their Apple Wallet so you can disable the button.

Steps to Reproduce

This is a bit difficult to reproduce as it requires entitlements from Apple. But the basics of it are:

  1. Create iOS project
  2. Add com.apple.developer.payment-pass-provisioning entitlement
  3. Add in check to see if a user can add a PaymentPass:
var pkPassLibrary = new PKPassLibrary();
var canAddPass = pkPassLibrary.CanAddPaymentPass(primaryAccountIdentifier);
  1. Deploy to testFlight (PKPassLibrary only works in testFlight)
  2. Add your card to the Apple Wallet.
  3. Go back and see if the "Add to Apple Wallet" button is disabled because of the result of pkPassLibrary.CanAddPaymentPass

Expected Behavior

pkPassLibrary.CanAddPaymentPass should tell me if a user a is unable to add a payment pass to their Apple Wallet

Actual Behavior

pkPassLibrary.CanAddPaymentPass always returns true and therefore tells me nothing.

Am I initialising PKPassLibrary() wrong or something? Is there any way to check if this is a bug in Xamarin?

Nick
  • 135
  • 8

1 Answers1

4

I did find the issue. For those that come after me you do need to ensure that you register your associatedApplicationIdentifiers with your payment provider (visa, mastercard, etc). Apple will only let you know about payment passes that are associated with your app. That association is created at the visa/mastercard/etc side of things and is communicated through the panReferenceId.

Nick
  • 135
  • 8
  • Hey Nick, did you also need to add entitlement com.apple.developer.pass-type-identifiers as well to get this working? The getting started guide doesn't really mention this as a requirement? – venturidoo Sep 10 '20 at 22:56
  • If anyone ever wonders about my above question. No - you don't explicitly need the wallet entitlement/`com.apple.developer.pass-type-identifiers`. - The regular in-app provisioning entitlement is enough `com.apple.developer.payment-pass-provisioning`. – venturidoo Sep 19 '20 at 00:20