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