estoy programando una aplicación en expo con react navigation y el problema que me tiene estancado actualmente es que simple y sencillamente no logro que el link abra correctamente en la aplicacion cerrada, es decir el link funciona correctamente solo cuando la aplicacion está abierta o en segundo plano pero en la aplicación cerrasa lo unico que pasa es que solo se abre la pagina inicial.
Mi codigo es el siguiente :
const prefix = Linking.makeUrl('/');
export default function App() {
const [isReady, setIsReady] = useState(false);
const [initialState, setInitialState] = useState();
const ref = useRef();
const { getInitialState } = useLinking(ref, {
prefixes: [prefix],
config: {
CambiarContrasena: "CambiarContrasena/:code"
}
});
const sessiontype = useSelector(state => state.userdata.sessiontype)
const dispatch = useDispatch()
useEffect(() => {
detectsession()
getInitialState()
.catch((error) => { console.log(error)})
.then(state => {
if (state !== undefined) {
setInitialState(state);
}
setIsReady(true);
})
}, [ getInitialState ]);
const detectsession = async()=>{
const token = await AsyncStorage.getItem('user-token')
if(token == null){
dispatch({type : 'OnUserSession', payload: {sessiontype: 1}})
} else {
dispatch({type : 'OnUserSession', payload: {sessiontype: 2}})
}
}
if (!isReady) {
return null;
}
if(sessiontype == 0){
return(
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<ActivityIndicator size="large" />
</View>
)
}else if(sessiontype == 1){
return (
<NavigationContainer initialState={initialState} ref={ref}>
<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>
)
}
}
Espero que puedan ayudarme
Edito: Acabo de hacer un console.log a getinitialstatus y por alguna razón que desconozco siempre regresa undefined