1

我已经在我的应用程序中实现了深度链接。我的应用程序正在使用添加的链接打开,但无法从一个链接获取查询参数

这是我的深度链接配置的代码

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',
      },
    },
  },
};

这是完整的链接:

https://myapp.com/reset_password?access-token=abcdw&client=abcdef&client_id=abcdef&config=default&expiry=1646292840&reset_password=true&token=abcd&uid=abc@gmail.com

我想从此链接获取访问令牌、客户端和 uid。我怎么才能得到它?

4

1 回答 1

0

这是我的工作示例:

导航.ts

Loading: {
  path:
    'Loading/:routeName/:key1?/:value1?/:key2?/:value2?/:key3?/:value3?',
  screen: 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)
}

最后是我用来返回应用程序的链接

billing-app://Loading/InviteScreen/refresh/true
于 2022-03-02T10:08:57.447 回答