微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用react native expo进行深层链接-不打开屏幕

如何解决使用react native expo进行深层链接-不打开屏幕

方案用户1与用户2共享了注册链接

用户2单击了链接

预期结果:应该会打开“注册”屏幕

实际结果:它没有打开而是打开了认的第一个导航器

点击链接:url:'exp://kj-97q.anonymous.metordunia.exp.direct:80 /-/ signup'

问题:请提出我在做什么错

export default class App extends React.Component {


componentDidMount (){
 // If the app is NOT already open and the app is opened by clicking an url-->handle an initial url on app opening
  Linking.getinitialURL().then( ( url)=>{
    const {path,queryParams }=Linking.parse(url);
console.log("path url  from if the app is NOT already opened get intiial url:",path);
console.log("path url quary parameter:",queryParams);
console.log(`Linked to app with path: ${path} and data: ${JSON.stringify(queryParams)}`);  
this.props.navigation.navigate(path,queryParams);

  
  });

  // If the app is YES already open and the app is opened by clicking an url-->handle an initial url on app opening
Linking.addEventListener("url",event=>{

  this.urlRedirect(event.url)
}

)


}



urlRedirect=(url)=>{
  if (! url) return;
  // parse and redirect to new url
  const {path,queryParams }=Linking.parse(url);
  console.log("path url if app is YES already opened add event listener :",queryParams);
console.log(`Linked to app with path: ${path} and data: ${JSON.stringify(queryParams)}`);
this.props.navigation.navigate(path,queryParams);


}
  1. 导航器详细信息

    const AppNavigator = createBottomTabNavigator({

       Login: {
         screen: Loginstack,path:login,},Signup: {
         screen: Signupstack,path:'signup',

    },

  2. 控制台日志

    从尚未打开应用程序开始的路径URL获取初始URL:注册

    path url quary参数:对象{}

    通过以下路径链接到应用:注册和数据:{}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。