react-native-passkit-wallet icon indicating copy to clipboard operation
react-native-passkit-wallet copied to clipboard

CanAddPasses doesn't work on Android

Open saamerm opened this issue 4 years ago • 3 comments

I made the AndroidX changes needed in the AndroidManifest and I used this code to add the wallet in my phone:

  const handleOnPress = async () => {
    PassKit.canAddPasses().then(async () => {
      await PassKit.addPass(
        idCardPassBase64,
        '$bundleId.fileprovider',
      )
    })
  }

Current Behavior


If I don't have a PKPass reading app installed, it still goes ahead and tries to add a pass on Android and throws an error:

Error: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://$bundleId.fileprovider/passkit/4aff4a73-9774-4c3b-8538-f0ab8439c7b2.pkpass typ=application/vnd.apple.pkpass flg=0x10000001 }

But if I have the app installed, it works fine and adds the pass to the wallet.

Expected Behavior:


  • CanAddPasses should return false and not actually try adding the pass.

Note: $bundleId is my app's bundle ID.

saamerm avatar Jun 30 '21 14:06 saamerm

Hi saamerm. The function works fine, but you don't process its return value properly. You should have a look into the proper use of .then(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then

At some point in your code you should have an if that checks whether the return value of canAddPasses is actually true or not, and then call addPass, or not.

TheWirv avatar Jul 21 '21 15:07 TheWirv

Hi guys, I have been doing tests with the fork of @TheWirv in Android but I have realized that the library does not support - detect native Google Pay to add passes. I have tested in a Android 10 Simulator with Android Studio and with a real device and neither of the 2 worked for me, canAddPasses always return false but when I use a third party application like Wallet Passes it works. (https://play.google.com/store/apps/details?id=io.walletpasses.android&hl=es_CO&gl=US). Any help would be appreciate.

carl0shd avatar Aug 31 '21 06:08 carl0shd

Hi guys, I have been doing tests with the fork of @TheWirv in Android but I have realized that the library does not support - detect native Google Pay to add passes. I have tested in a Android 10 Simulator with Android Studio and with a real device and neither of the 2 worked for me, canAddPasses always return false but when I use a third party application like Wallet Passes it works. (https://play.google.com/store/apps/details?id=io.walletpasses.android&hl=es_CO&gl=US). Any help would be appreciate.

I believe because GPay doesn't support pkpass file.

frost4869 avatar Jan 06 '22 11:01 frost4869