Hi,
I am testing my app with TestFlight. The app is developed with React Native Expo.
Step 1: Log into the app – everything works fine.
Step 2: Use the app – everything works fine.
Step 3: Close the app without logging out, just close it.
Step 4: Remove the app from the recent apps window.
Step 5: Try to open the app again, but it requires login again.
I don’t understand why the login parameters are not retained and why the app asks me to log in again.
Code used for login handling:
import AsyncStorage from "@react-native-async-storage/async-storage";
useEffect(() => {
const loadToken = async () => {
const token = await AsyncStorage.getItem(TOKEN_KEY);
if(token) {
axiosInstance.defaults.headers.common['Authorization'] = `Bearer ${token}`;
try {
const response = await axiosInstance.get('/auth/check');
const data = response.data;
setSession(token);
setUser(data.user);
} catch (e) {
setSession(null);
setUser(null);
}
}
}
loadToken().then(() => setIsLoading(false));
}, []);
Important Note:
This issue only occurs when we switch to production. In the test environment, everything works fine, and we don’t experience this problem. However, as soon as we build for production and test on multiple devices, this issue appears.
Thanks in advance!