react-navigation / react-navigation

Routing and navigation for your React Native apps
https://reactnavigation.org
23.59k stars 5.04k forks source link

Wrong redirect from notification when app is closed #10752

Closed cedricls1 closed 2 years ago

cedricls1 commented 2 years ago

Current behavior

Hello,

I did a serie of tests with the same link. I sent a notification on my phone and 7 times out of 20, the app opened on the home page and not the link of my notification with this warning :

The navigation state parsed from the URL contains routes not present in the root navigator. This usually means that the linking configuration doesn't match the navigation structure.

The navigation seems not ready. When the app is open, I don't have the problem.

We use this code : export async function getInitialURL(): Promise<string> { const dynamicLinkUrl = await dynamicLinks().getInitialLink() if (dynamicLinkUrl) { return dynamicLinkUrl.url } // Little break to avoid to have null link //await new Promise((r) => setTimeout(r, 500)) const url = await BatchPush.getInitialURL() if (url) { return url } return WEBAPP_V2_URL }

When I used the setTimeout I don't have problem but it's not optimal

Thanks by advance for your help

Expected behavior

Be redirected on my notification link everytime

Reproduction

https://github.com/pass-culture/pass-culture-app-native

Platform

Packages

Environment

package version
@react-navigation/native ^6.0.6
@react-navigation/bottom-tabs ^6.0.9
@react-navigation/stack ^6.0.11
github-actions[bot] commented 2 years ago

Hey! Thanks for opening the issue. The issue doesn't seem to contain a link to a repro (a snack.expo.dev link, a www.typescriptlang.org/play link or link to a GitHub repo under your username).

Can you provide a minimal repro which demonstrates the issue? Please try to keep the repro as small as possible and make sure that we can run it without additional setup.

A repro will help us debug the issue. The issue will be closed automatically after a while if you don't provide a repro.

github-actions[bot] commented 2 years ago

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

github-actions[bot] commented 2 years ago

Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it.

satya164 commented 2 years ago

As the warning says, your linking config doesn't match the navigation structure. You should review your linking config and make sure that the structure matches how you're nesting your screens. https://reactnavigation.org/docs/configuring-links/

If you still have issues, please open an issue with a minimal repro.

github-actions[bot] commented 2 years ago

Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro.