The parameter of react navigation deeplink comes out as undefined only when the app is closed

421 Views Asked by At

I am implementing react native/android/react navigation deeplink.

And I'm using react-native v0.68, react-navigation v6.xx

https://reactnavigation.org/docs/configuring-links/

  1. In the case of foreground or background in the app open state, insert parse into deeplink and touch the link in the messenger to move to the corresponding path and check the value of params.

  2. If the same deeplink is touched while the app is closed, it moves to the path, but the parse value is confirmed as undefined.

process of number 2

2-1 Enter the video below in the terminal and check it in the android emulator. npx uri-scheme open myapp://init/main/home/eventdetails/1234 --android or, After building the apk, link myapp://init/main/home/eventdetails/1234 on the pysical device.

2-2 After the app opens, go to that path.

2-3 check the param value with console.log, undefined is displayed.

`

const linking = {
    prefixes: ["myapp://"],
    Config: {
      screens: {
        init: {
          path: "init",
          initialRouteName: "main",
          screens: {
            main: {
              path: "main",
              screens: {
                home: {
                  path: "home",
                  screens: {
                    eventlist: {
                      path: "eventlist",
                    },
                    eventdetails: {
                      path: "eventdetails/:id",
                      parse: {
                        id: (id: any) => `${id}`,
                      },
                    },
                    screens: {
                      truckdetails: {
                        path: "truckdetails/:id",
                        parse: {
                          id: (id: any) => `${id}`,
                        },
                      },
                    },
                  },
                },
              },
            },
          },
        },
      },
    },
  };

`

when the app is open. `

Object {
   "initial": true,
   "params": undefined,
   "path": "init/main/home/eventdetails/1234",
   "screen": "1234",
   "state": undefined,
} :::params

`

when the app is closed. undefined :::params

Even when the app is closed, I want to check the parse value on the react native screen in the same way as when it is open.

0

There are 0 best solutions below