Pass params in react native dynamic links

2.6k Views Asked by At

I'm using @react-native-firebase/dynamic-links to handle firebase dynamic links inside the react native app.

I've created a dynamic link https://example.page.link/settings and I'd like to have an option where I could click on the link that looks like https://example.page.link/settings?account or https://example.page.link/settings?notifications and it would take me to the account or notification screen inside the settings.

using:

dynamicLinks().onLink(async (link) => {
  console.log({ link });
});

when I click on https://example.page.link/settings?account, I only receive an object that contains url (that doesn't contain params - just https://example.page.link/settings) and minimumAppVersion`.

I've noticed that if I create a short link inside the firebase console https://example.page.link/settings and in the second step I put https://example.page.link/settings?account as a deeplink, then when I click on a short link I would receive the link with account param, but that doesn't solve my problem as I would have to create a separate short link with different deeplink that has a hardcoded params

What is the right way to go with this using Firebase dynamic links if I want to see params inside my app, or for this use case I will have to go with a custom solution and not use firebase?

1

There are 1 best solutions below

2
On

For a nested navigations using Dynamic links, we can create a link in a way that we can access to navigate to the specific screen.

like, if we needed to navigate to the settings screen and then, the account screen or notifications screen then, we have to set the URL in a way to navigate to the specific screen.

have a try with the below link

https://example.page.link/settings/account

Instead of the previous try

https://example.page.link/settings?account

we are also able to use deep linking to open the specific screen with react-navigation.

checkout the official docs of react-navigation to implement deep linking:

https://reactnavigation.org/docs/deep-linking/