Skip to content

Instantly share code, notes, and snippets.

@Salakar
Created June 8, 2018 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Salakar/e88386dd8985eca2318ea35b5318c472 to your computer and use it in GitHub Desktop.
Save Salakar/e88386dd8985eca2318ea35b5318c472 to your computer and use it in GitHub Desktop.
Logout app after version change pseudo code
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
}
@Salakar
Copy link
Author

Salakar commented Jun 8, 2018

@Salakar
Copy link
Author

Salakar commented Jun 8, 2018

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