Guest User

Untitled

a guest
Nov 2nd, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import * as Keychain from 'react-native-keychain';
  2.  
  3. async () => {
  4. const username = 'zuck';
  5. const password = 'poniesRgr8';
  6.  
  7. // Store the credentials
  8. await Keychain.setGenericPassword(username, password);
  9.  
  10. try {
  11. // Retreive the credentials
  12. const credentials = await Keychain.getGenericPassword();
  13. if (credentials) {
  14. console.log('Credentials successfully loaded for user ' + credentials.username);
  15. } else {
  16. console.log('No credentials stored')
  17. }
  18. } catch (error) {
  19. console.log('Keychain couldn\'t be accessed!', error);
  20. }
  21. await Keychain.resetGenericPassword()
  22. }
Add Comment
Please, Sign In to add comment