Expo / React Navigation深层链接无法在关闭的应用程序上运行

时间:2020-11-05 03:16:33

标签: react-native expo react-navigation

我制作了一个本机应用程序,我需要在especific链接的特定屏幕上打开应用程序(在这种情况下,更改密码屏幕),我的问题是深层链接仅适用于打开的应用程序,而不适用于关闭的应用程序。这是我的代码:

const prefix = Linking.makeUrl('/');

export default function App() {
    const linking = {
      prefixes: [prefix],
      config: {
          screens :{
            CambiarContrasena: "CambiarContrasena/:id"
          }
      }
    }
    const sessiontype = useSelector(state => state.userdata.sessiontype)
    const dispatch = useDispatch()


    useEffect(() => {
        detectsession()
    }, [ ]);

    const detectsession = async()=>{
        const token = await AsyncStorage.getItem('user-token')
        if(token == null){
            dispatch({type : 'OnUserSession', payload: {sessiontype: 1}})
            const url = await Linking.getInitialURL();
            console.log(url)
        } else {
            dispatch({type : 'OnUserSession', payload: {sessiontype: 2}})
        }

    }
    if(sessiontype == 2){
        return(
            <NavigationContainer>
                <AppStack.Navigator headerMode='none' initialRouteName="Login">
                    <AppStack.Screen name="Resumen" component={Resumen}/>
                    <AppStack.Screen name="Averias" component={Averias}/>
                    <AppStack.Screen name="Equipos" component={Equipo}/>
                    <AppStack.Screen name="Equipo1" component={Equipo1}/>
                    <AppStack.Screen name="CargarAveria" component={CargarAveria}/>
                    <AppStack.Screen name="GenerarReporte" component={GenerarReporte}/>
                    <AppStack.Screen name="RegistroMantenimiento" component={RegistroMantenimiento}/>
                    <AppStack.Screen name="EditarBuques" component={EditarBuques}/>
                    <AppStack.Screen name="Grupos" component={Grupos}/>
                    <AppStack.Screen name="SubGrupos" component={SubGrupos}/>
                    <AppStack.Screen name="Historial" component={Historial}/>
                    <AppStack.Screen name="Buques" component={Buque}/>
                    <AppStack.Screen name="Logs" component={Log}/>
                    <AppStack.Screen name="GrupoPrincipal" component={GrupoPrincipal}/>
                    <AppStack.Screen name="Tareas" component={Tareas}/>
                </AppStack.Navigator>
            </NavigationContainer>

        )
    }

    return (
        <NavigationContainer linking={linking}>
            <Auth.Navigator headerMode='none'>
                <Auth.Screen name="Login" component={Login} />
                <Auth.Screen name="VerificationCode" component={VerificationCode} />
                <Auth.Screen name="CambiarContrasena" component={CambiarContraseña} />
                <Auth.Screen name="ReestablecerContraseña" component={ReestablecerContraseña} />
            </Auth.Navigator>
        </NavigationContainer>
    )
}

有一个步骤我找不到吗?我阅读了expo的文档并做出了反应,但找不到解决方法

0 个答案:

没有答案