Please provide the following:
- SDK Version: 41
- Platforms(Android/iOS/web/all): oOS
- Add the appropriate “Tag” based on what Expo library you have a question on.
expo-secure-store
I store an user by expo-secure-store and in android, I don’t need to relogin in an user after restart. But in ios I must. Why?
Parts of my code:
"
const [state, dispatch] = React.useReducer(
(prevState, action) => {
switch (action.type) {
case ‘RESTORE_TOKEN’:
return {
…prevState,
userToken: action.token,
isLoading: false,
};
case ‘SIGN_IN’:
return {
…prevState,
isSignout: false,
userToken: action.token,
};
case ‘SIGN_OUT’:
return {
…prevState,
isSignout: true,
userToken: null,
};
}
},
{
isLoading: true,
isSignout: false,
userToken: null,
}
);
",
"
React.useEffect(() => {
// Fetch the token from storage then navigate to our appropriate place
const bootstrapAsync = async () => {
let userToken;
try {
userToken = await SecureStore.getItemAsync(‘key’);
// userToken = true;
} catch (e) {
// setIsLoading(true);
}
// After restoring token, we may need to validate it in production apps
// This will switch to the App screen or Auth screen and this loading
// screen will be unmounted and thrown away.
dispatch({ type: 'RESTORE_TOKEN', token: userToken });
};
bootstrapAsync();
}, []);
"