Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
- }
Add Comment
Please, Sign In to add comment