React native login does not retain when app get restarted

Followed the Quickstart guide for Auth0 React Native App but the iOS app does not retain logged in state when the app is restarted.

Steps:

  1. Open iOS App
  2. Initial Universal Login
  3. Complete Login
  4. User now in Logged In State
  5. Close the App
  6. Re-open the App

Expected:
App opens in Logged In State

Actual:
App opens in Login Page

const { user } = useAuth0()

// user will always be null 

Hello, @archie
When integrating Auth0 with a React Native app, ensuring that the app retains the logged-in state after restarts is crucial. You can do some steps to address this issue: Persistent Authentication State: To maintain the user’s logged-in state across app restarts, consider using a persistent storage mechanism. Store User Info: When the user logs in successfully, store relevant information (such as tokens or user profile data) securely. Use AsyncStorage or a similar solution to save this data. Check Token Expiry:
Ensure that your access tokens have a reasonable expiry time. If a token expires, the user will need to log in again. Handle App Lifecycle Events:
Listen for app lifecycle events (e.g., AppState changes) to trigger actions when the app resumes. When the app reopens, check if the user is still authenticated and restore their session accordingly. Test on Real Devices:
Sometimes issues related to state persistence behave differently on simulators/emulators vs. real devices. Test thoroughly on actual iOS devices to ensure consistent behavior. Remember that maintaining authentication state across app restarts involves a combination of token management, storage, and handling app lifecycle events. I hope this info useful to you,
Best regard
MaximTimeClock