Created
June 8, 2018 13:34
-
-
Save Salakar/e88386dd8985eca2318ea35b5318c472 to your computer and use it in GitHub Desktop.
Logout app after version change pseudo code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { version } = require('./package.json'); | |
// ... inside your app startup logic | |
try { | |
const storedVersion = await AsyncStorage.getItem('@MyStore:appVersion'); | |
if (storedVersion !== version){ | |
// do logout logic here | |
// then update the stored version to be the newest version so next | |
// restart of app won't trigget this again | |
await AsyncStorage.setItem('@MyStore:appVersion', version); | |
} else { | |
// continue as normal | |
} | |
} catch (error) { | |
// Error retrieving data | |
} |
You might not need to logout on every app version - so you could create a different property on your root package.json
and just use that (by changing it) to force a logout if that specific build needed it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://facebook.github.io/react-native/docs/asyncstorage.html - for reference