I have multiple key, value
and I dont know how can I store multiple key, value
in different places.
Is there an alternative way for the following code using react-native-keychain
package ??
await AsyncStorage.setItem('pincode', '12345');
await AsyncStorage.setItem('userid', '@user8383928');
await AsyncStorage.setItem('contacts', JSON.stringify(contacts_array_of_object));
Every above key, value saving
may called in different functions and in a different time.
Problem is in react-native-keychain
there is only two property username, password
:
async () => {
const username = 'zuck';
const password = 'poniesRgr8';
// Store the credentials
await Keychain.setGenericPassword(username, password);
try {
// Retrieve 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();
}