Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot get correct value from pkPassLibrary.CanAddPaymentPass in Xamarin.iOS

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?

like image 449
Nick Avatar asked Oct 17 '25 06:10

Nick


1 Answers

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.

like image 120
Nick Avatar answered Oct 18 '25 20:10

Nick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!