Last active
November 3, 2018 16:46
-
-
Save adhithiravi/91c849dd5f2ad202bf8652c0050334cf 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'; | |
import DeviceInfo from 'react-native-device-info' | |
async () => { | |
const username = 'adhithi'; | |
const password = 'poniesRgr8'; | |
const server = DeviceInfo.getBundleId() | |
// Store the credentials | |
await Keychain.setInternetCredentials(server, email, password).then(() => { | |
try { | |
// Retreive the credentials | |
const credentials = await getInternetCredentials(server); | |
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.resetInternetCredentials(server) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment