[英]How can I open Tez app (Google Pay app in India) programmatically in React Native in Android?
在印度,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中實現這一目標?
我創建了一個npm包,以使ReactNative開發人員能夠接受移動應用程序上的付款。
https://www.npmjs.com/package/react-native-google-pay-tez
嘗試這個。
注意:Google僅支持android意圖通過已安裝的google pay應用接受付款。 對於iOS,您必須使用全向渠道,您必須與其聯系。
我找到了以下模塊: 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”:“必須是字符串”}))。then(( 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");
}
});
}
});}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.