tomavic / cordova-apple-wallet

A Cordova plugin that provides easy use for adding your credit/debit cards to Apple Wallet. It also can check if the credit/debit card exists in Wallet or any paired device e.g. Apple Watch
Apache License 2.0
44 stars 52 forks source link

Support for containsPass method #42

Open mg opened 2 years ago

mg commented 2 years ago

Hi and thank you for this plugin.

There is a problem with using checkPairedDevicesBySuffix to check if card is already in the wallet, and it is because those 4 numbers are not guaranteed to be unique. I for example have two different cards that share the same last 4 digits, and therefore this method will return true for a card that has not been added to the wallet if another card with the same suffix has previously been added to the wallet.

Apple provides a method to check if a Pass is in the wallet, the containsPass method. Sadly, my Objective C skills are somewhat lacking, and Apples documentation on how to use this method is even more lacking

https://developer.apple.com/documentation/passkit/pkpasslibrary/1617110-containspass?language=objc

Is it possible to add support for this method that accepts the params we have that uniquely identifies the card that we are adding, i.e. the primaryAccountIdentifier.

Sadly and for reasons I cannot understand, the primaryAccountIdentifier we supply when adding a pass, and primaryAccountIdentifier we get back when enumerating cards through passLib passesOfType:PKPassTypePayment are not the same number. If it was we could change the checkPairedDevicesBySuffix to work correctly (e.g. search for the primaryAccountIdentifier, not the primaryAccountSuffix).

Cheers and thanks again for this plugin.

tomavic commented 2 years ago

Hello @mg

I hate to say that but I don't have the luxury to work on this plugin at the moment. I appreciate your help if you want to create a Pull request with the required changes.

Thanks ❤️

thib-lambert commented 2 months ago

@mg You can try to use this SDK and the method getActionsAvailableForCardSuffix. This method returns an array of integer so you have 3 cases: