Tez是印度一种流行的付款方式。
tezFunc()
{
const url = 'com.google.android.apps.nbu.paisa.user://';
Platform.OS === 'android' ?
Linking.canOpenURL(url).then(supported => {
if (!supported) {
Linking.openURL('https://play.google.com/store/apps/details?id=com.google.android.apps.nbu.paisa.user&hl=en_IN')
}else {
return Linking.openURL(url);
}
}).catch(err => console.error('An error occurred', err))
:
Linking.openURL('https://itunes.apple.com/in/app/google-pay-for-india-tez/id1193357041?mt=8')
}
在这里,我将应用程序的分发包ID作为URL传递。这样做的方式是,每当Play商店开放时,我都不知道该如何实现。我想打开该应用程序(如果它存在于设备中),否则请打开Play商店链接。
但是在WhatsApp的情况下我已经实现了这一点,但是在Tez的情况下却无法正常工作。
在WhatsApp正常运行的情况下
_whatsaap = () =>
{
const url = 'whatsapp://send?text=. I have an enquiry, please reply me ASAP!&phone=**********';
Linking.canOpenURL(url).then(supported => {
if (!supported) {
Alert.alert(
'Comet Graphic',
'Sorry, The app is not installed in your device! Press OK to install it now!',
[{
text: 'OK', onPress: () =>Linking.openURL(' https://play.google.com/store/apps/details?id=com.whatsapp') },
{text: 'Cancel'},
], {
cancelable: false
}
)
如何在Tez中实现这一目标?
答案 0 :(得分:2)
我创建了一个npm软件包,以使ReactNative开发人员能够接受移动应用程序上的付款。
https://www.npmjs.com/package/react-native-google-pay-tez
尝试一下。
注意:Google仅支持Android意向通过已安装的Google Pay应用接受付款。对于iOS,您必须使用全渠道,您必须与他们联系。
答案 1 :(得分:1)
我找到了以下模块:https://www.npmjs.com/package/react-native-send-intent#example--check-if-an-application-is-installed
我认为您可以尝试以下方法:
使用以下方法检查用户设备上是否安装了应用程序: SendIntentAndroid.isAppInstalled('com.google.android.gm')。then((isInstalled)=> {});
如果已安装,请运行:
SendIntentAndroid.openApp('com.google.android.gm')。then((wasOpened)=> {});
,如果要传递其他参数,请使用:
SendIntentAndroid.openApp('com.mycorp.myapp',{“ com.mycorp.myapp.reason”:“仅因为”,“ com.mycorp.myapp.data”:“必须是字符串”})。然后((wasOpened)=> {});
我不确定这是如何工作的,但据我所知,您可以使用以下命令直接安装apk:
SendIntentAndroid.installRemoteApp('https://example.com/my-app.apk','my-saved-app.apk')。then((installWasStarted)=> {});
更新: 请尝试以下示例代码:
_tez = () => {
SendIntentAndroid.isAppInstalled('com.tez.blablabla').then((isInstalled) => {
if (isInstalled) {
SendIntentAndroid.openApp('com.google.android.gm').then((wasOpened) => {
if (wasOpened) {
console.log("App opened");
}
else {
console.log("Error opening app or it was not opened");
}
});
}
});}