Home > Software engineering >  Reading Url with React Native Deep Linking
Reading Url with React Native Deep Linking

Time:11-26

I am using a deep link which sends me to my app in a specific page but I want to read the link it that page. For example: My link is "my app://somepage/code=123", I want to take this code value from url after I open the link.

CodePudding user response:

You just need to take the params from route

const Example = ({navigation, route})=>{
  const code = route.params.code;
}

CodePudding user response:

Ok, I found a method which allows me to run a function whenever I open my page.

 useEffect(() => {
    navigation.addListener('focus', () => {
      getCode();
    });
  }, []);
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

In the getCode function, I'm using getInitialUrl() function, here is the docs for more info, https://reactnative.dev/docs/linking#getini… You can use this module to collect the coming url and do whatever you want.

  • Related