I have a deeplinking configuration setup to open a specific page when a URL is clicked on the device. This is working fine when the app is open in the background, but if the app is closed, it just opens the app and does not navigate.
Here is my linking configuration:
const linking = {
prefixes: ["appname://"],
config: deepLinkRouting,
getStateFromPath(path:string, options:any) {
//build custom params
},
async getInitialURL() {
// Check if app was opened from a deep link
const url = await Linking.getInitialURL();
if (url != null) {
return url;
}
},
subscribe(listener) {
const onReceiveURL = ({ url }) => listener(url);
Linking.addEventListener('url', onReceiveURL);
return () => {
// Clean up the event listener
Linking.removeEventListener('url', onReceiveURL);
};
},
}
This linking object is provided as a prop to my <NavigationContainer/>
I am testing this on simulator with the npx uri-scheme open command. I notice when you close the app and reopen it, the app is rebuilt, so I'm wondering if this invalidates testing. Any help is appreciated!