how to get a query params in react native deep linking

3.8k Views Asked by At

I have implemented deep linking in my app. My app is opening using added links but unable to get query params from one link

here is the code of my deep linking config

const linking = {
  prefixes: ['demo://'],
  config: {
    screens: {
      Signup: {
        path: 'SignUp',
      },
      SignupInvitation: {
        path: 'user/invite/invite_code/:invitecode',
        parse: {
          invitecode: (invitecode: string) => {
            console.log('Code ', invitecode);
            storeToken(invitecode);
            return `${invitecode}`;
          },
        },
      },
      ResetPassword: {
        path: 'reset_password',
      },
    },
  },
};

here is the complete link:

https://myapp.com/reset_password?access-token=abcdw&client=abcdef&client_id=abcdef&config=default&expiry=1646292840&reset_password=true&token=abcd&[email protected]

I want to get access-token, client, and uid from this link. how can I get it?

1

There are 1 best solutions below

1
On

Here is my working example:

navigations.ts

Loading: {
  path:
    'Loading/:routeName/:key1?/:value1?/:key2?/:value2?/:key3?/:value3?',
  screen: Loading,
},

Loading.tsx

const Loading = ({{ navigation }}) => {
const routeName = navigation.getParam("routeName")
useEffect(() => {
  const params = {
    [navigation.getParam("key1")]: navigation.getParam("value1"),
    [navigation.getParam("key2")]: navigation.getParam("value2"),
    [navigation.getParam("key3")]: navigation.getParam("value3"),
  }
  console.log({ params })
})
navigation.navigate(routeName, params)
}

and finally the link I use for returning back to the app

billing-app://Loading/InviteScreen/refresh/true