I'm not familiar with React Native so I can't give you React Native specific answers but you may be able to adapt the following answers for React Native.
I am trying to deep-link to a specific Google Pay pass on the Google pay app. For example, if the user taps on a link, they should be directly be redirected to pass installed on their Google Pay app.
Similarly I would also like to check if the pass is installed or not their phone and if the Google Pay app is installed on the phone as well.
You can achieve this with a Save to Google Pay link and launching an intent with the save URI. See example:
activityBinding.content.saveButton.setOnClickListener {
val uri = Uri.parse("https://pay.google.com/gp/v/save/$jwt")
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
}
The handling of the intent typically has the following behaviors:
- If Google Pay is available on the device, it can launch Google Pay
- If the pass is already saved, it will show that the pass has already been saved with an option to remove or to view the pass
- If the pass hasn't been saved, it will save it with the option to remove or view the pass
- If Google Pay isn't available, it will open the link in a browser with similar saved/unsaved behavior above.
Using this approach you don't technically need to check to see if the pass has been saved, or if Google Pay is available. Note that passes can be saved even if the Google Pay app isn't installed.
If you'd like more information on how to generate a jwt
, refer to https://developers.google.com/pay/passes/guides/implement-the-api/save-passes-to-google-pay?hl=en&feed=email-sms#generate-jwt-that-represents-object
There's also a Codelab available if you'd like a step by step guide which includes code samples on creating jwt
with a nodejs backend.
If you must check to see if Google Pay is installed, you should be able to query it using this answer: https://stackoverflow.com/a/18752247/12031739
Note that the Google Pay package name may vary depending on region of the world you are in so you'll want to check which package name applies to you.