react-native-passkit-wallet
react-native-passkit-wallet copied to clipboard
CanAddPasses doesn't work on Android
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.
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.
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.
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.