0

我有一个应用程序,我想通过深度链接进行付款。我有一些在应用程序启动时调用的 api,所以在从付款回来后我想再次启动应用程序这是我的链接抛出 url

const goToFeedback = () => {
    setLoading(true);
    sendTransactionPay({
      walletUrl,
      walletId,
      callback: id => {
        Linking.canOpenURL(`${paymentUrl}\/${id}`).then(supported => {
          if (supported) {
            Linking.openURL(`${paymentUrl}\/${id}`);
          } else {
            changeEvent({
              showModal: false,
              modalMessage: 'error',
              info: false,
            });
          }
        });
      },
    });
  };

不幸的是,从付款网址返回后,当前组件已显示。这是我的清单

<activity
            android:name=".MainActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
            android:label="@string/app_name"
            android:excludeFromRecents="true"
            android:alwaysRetainTaskState="true"
            android:launchMode="singleTask"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter android:label="@string/app_name">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="app" android:host="avachain" />
            </intent-filter>
        </activity>
4

1 回答 1

1

使用这个库(不要忘记做本地链接):

https://www.npmjs.com/package/react-native-restart

然后您可以使用一个功能重新启动您的 rn 应用程序:

import RNRestart from 'react-native-restart'; // Import package from node modules

// Immediately reload the React Native Bundle
RNRestart.Restart();
于 2020-04-25T16:20:55.933 回答