簡體   English   中英

深度鏈接后如何重啟本機應用程序

[英]How to restart react native app after deep linking

我有一個應用程序,我想通過深度鏈接進行支付。 我有一些在應用程序啟動時調用的 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,
            });
          }
        });
      },
    });
  };

不幸的是,從付款 url 返回后,當前組件已顯示。 這是我的清單

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

使用此庫(不要忘記進行本機鏈接):

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

然后你可以使用一個 function 重啟你的 rn 應用程序:

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM