[英]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我有一些在应用程序启动时调用的 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,
});
}
});
},
});
};
unfortunately after return from payment url the current component has shown.不幸的是,从付款 url 返回后,当前组件已显示。 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 https://www.npmjs.com/package/react-native-restart
Then you can restart your rn app using one function:然后你可以使用一个 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.