expo-secure-store does not store information in ios after restart

Please provide the following:

  1. SDK Version: 41
  2. Platforms(Android/iOS/web/all): oOS
  3. 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();

}, []);

"

Hey @yurko_ogurko, can you please provide a reproducible example without any additional code or complexity? Your reducer logic adds unnecessary noise here. A simple implementation of get and set for an item will do.

I will say that I have a side project that is using securestore on iOS without any issues, even upon device restarts. So I’m inclined to believe this is an implementation issue but perhaps not!

Cheers,
Adam

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.