Skip to content

Instantly share code, notes, and snippets.

@adhithiravi
Last active November 2, 2018 04:33
Show Gist options
  • Save adhithiravi/4ab75b63cb4db09728ef53d7c7fd420b to your computer and use it in GitHub Desktop.
Save adhithiravi/4ab75b63cb4db09728ef53d7c7fd420b to your computer and use it in GitHub Desktop.
import * as Keychain from 'react-native-keychain';
async () => {
const username = 'zuck';
const password = 'poniesRgr8';
// Store the credentials
await Keychain.setGenericPassword(username, password);
try {
// Retreive the credentials
const credentials = await Keychain.getGenericPassword();
if (credentials) {
console.log('Credentials successfully loaded for user ' + credentials.username);
} else {
console.log('No credentials stored')
}
} catch (error) {
console.log('Keychain couldn\'t be accessed!', error);
}
await Keychain.resetGenericPassword()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment