简体   繁体   中英

How to restart react native app after deep linking

I have an app that I want to do payment with deep linking. I have some apis that are called at the start of the app so after getting back from payment I want to start app again this is my linking throw the 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,
            });
          }
        });
      },
    });
  };

unfortunately after return from payment url the current component has shown. this is my manifest

<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>

Use this library (don't forget to do native linking):

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

Then you can restart your rn app using one function:

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

// Immediately reload the React Native Bundle
RNRestart.Restart();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM