Last active
November 2, 2018 04:33
-
-
Save adhithiravi/4ab75b63cb4db09728ef53d7c7fd420b to your computer and use it in GitHub Desktop.
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
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