Hi everyone!
I have a problem when I open the application from a deep link: the navigation stack does not load and I can’t navigate inside the app.
Stage: The app is killed and a deep link opens the app. The app opens and navigates to the screen specified in the deep link but I can’t do anything else (e.g: go to the previous screen) because it doesn’t load my stack.
I have this:
- scheme: myapp
App.tsx:
const Stack = createStackNavigator()
<NavigationContainer linking={LinkingConfiguration} onReady={async () => await getInitialURL()}>
* my stack *
</NavigationContainer>
const getInitialURL = async () => {
const url = await Linking.getInitialURL();
if (url != null) {
return url
}
}
LinkingConfiguration file:
prefixes: ["myapp://"]
config: { myConfiguration },
subscribe(listener) {
const onReceiveURL = ({ url }: { url: string }) => {
listener(url)};
// Listen to incoming links from deep linking
Linking.addEventListener('url', onReceiveURL);
return () => {
// Clean up the event listeners
Linking.removeEventListener('url', onReceiveURL);
subscription.remove();
};
},
I tried to set a timeout before returning the url but it didn’t work.
Could you help me?