Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CanAddPasses doesn't work on Android #19

Open
saamerm opened this issue Jun 30, 2021 · 3 comments
Open

CanAddPasses doesn't work on Android #19

saamerm opened this issue Jun 30, 2021 · 3 comments

Comments

@saamerm
Copy link

saamerm commented Jun 30, 2021

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.

@TheWirv
Copy link

TheWirv commented Jul 21, 2021

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.

@carl0shd
Copy link

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.

@frost4869
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants