React Native - 当应用程序不在后台时深度链接不起作用(Android,iOS)
React Native - Deep linking is not working when app is not in background (Android, iOS)
- 如果应用程序在后台
specific screen will open.
- 如果应用程序不在后台或终止应用程序
it will show first screen only.
Linking.getInitialURL() is return null
如果你想在应用程序被杀死或尚未启动的情况下进行重定向,请找到以下简单的解决方案:
// Don't forget to import
import {
Linking
} from 'react-native';
useEffect(() => {
const getAsyncURL = async () => {
const initialUrl = await Linking.getInitialURL();
if (initialUrl != undefined && initialUrl != null){
// Handle initialURL as per your response and open a specific screen using navigation
}
};
getAsyncURL();
}, []);
*// 上面的解决方案对我有用
- 如果应用程序在后台
specific screen will open.
- 如果应用程序不在后台或终止应用程序
it will show first screen only.
Linking.getInitialURL() is return null
如果你想在应用程序被杀死或尚未启动的情况下进行重定向,请找到以下简单的解决方案:
// Don't forget to import
import {
Linking
} from 'react-native';
useEffect(() => {
const getAsyncURL = async () => {
const initialUrl = await Linking.getInitialURL();
if (initialUrl != undefined && initialUrl != null){
// Handle initialURL as per your response and open a specific screen using navigation
}
};
getAsyncURL();
}, []);
*// 上面的解决方案对我有用