0

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 中实现这一点?

4

2 回答 2

2

I have created a npm package for enabling ReactNative developers to accept payments on mobile application.

https://www.npmjs.com/package/react-native-google-pay-tez

Try this.

Note : Google only supporting android intent for accepting payments through installed google pay app. For iOS you'll have to use omni channel for which you'll have to contact them.

于 2019-07-01T21:03:26.860 回答
1

我找到了以下模块:https ://www.npmjs.com/package/react-native-send-intent#example--check-if-an-application-is-installed

我认为您可以尝试以下方法:

  1. 使用以下命令检查应用程序是否安装在用户设备上:SendIntentAndroid.isAppInstalled('com.google.android.gm').then((isInstalled) => {});

  2. 如果安装运行:

    SendIntentAndroid.openApp('com.google.android.gm').then((wasOpened) => {});

    如果您想传递其他参数,请使用:

    SendIntentAndroid.openApp('com.mycorp.myapp', {"com.mycorp.myapp.reason": "只是因为", "com.mycorp.myapp.data": "必须是字符串"}).then((已打开) => {});

我不确定这是如何工作的,但据我所知,您可以直接使用以下方法安装 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");
            }
        });
    }
});}
于 2018-10-24T07:59:16.140 回答