Guest User

Untitled

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