AsyncStorage data persistence

I’ve been using AsyncStorage to store JWT token however after a while and on some occasions, I get back the data as null.

I store the keys like below

await AsyncStorage.multiSet([
        ['JWT', token],
        ['tenancyID', tenancyID.toString()],
        ['email', email],
        ['password', password]
      ])

ad retrieve the token like below

const tenancyID = await AsyncStorage.getItem('tenancyID')
const email = await AsyncStorage.getItem('email')
const password = await AsyncStorage.getItem('password')

Although most of the time I get back the correct values, whenever I quit the application and restart, the data is coming back as null hence not persisting. What am I potentially doing wrong ? The examples have an ‘@’ in the beginning of the setItem, but I’m not sure if that is required for data persistence?

Hey @msert,

Is this occurring on both Android and iOS? Also, what SDK version is your project running? It’s going to be hard to tackle this without a repo case, but that information will be a good start.

Cheers,
Adam

Sorry forgot to attach does details.

It is occurring on IOS, Expo version 27.

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