Open agieocean opened 1 year ago
Did you find a solution to this issue, I have the same problem.
I have a similar problem while trying to use setGenericPassword. Would highly appreciate any help with this if anyone was able to resolve it.
Expected behavior is to be able to store the tokens and retrieve using await Keychain.getGenericPassword();
I however encounter the following error while trying to set:
Cannot read property 'setGenericPasswordForOptions' of null
and
Keychain Error: Cannot read property 'getGenericPasswordForOptions' of null
while trying to get.
const onLogin = async () => {
setLoading(true);
axios
.post(`/login`, {
email,
password,
})
.then(async (res) => {
const { accessToken, refreshToken } = res.data;
setAuthState({ accessToken, refreshToken, authenticated: true });
Keychain.setGenericPassword(
'token',
JSON.stringify({ accessToken, refreshToken })
)
.then((value) => console.log(value))
.catch((e) => console.error(e));
})
.catch((err: AxiosError) => {
Alert.alert('Login Failed', 'Something went wrong');
})
.finally(() => {
setLoading(false);
});
};
Same
Same error
same error. tragic 🥶
"react-native": "0.72.6",
"react-native-keychain": "^8.1.2",
Hey, I managed to solve my problem. It was an oversight, I realized I can't user react-native-keychain in expo. So incase you are using expo, you could opt for SecureStore
Hey, I managed to solve my problem. It was an oversight, I realized I can't user react-native-keychain in expo. So incase you are using expo, you could opt for SecureStore
I just read @dannywamuya's comment after I learned expo managed workflow can't use react-native-keychain. and I solved it using SecureStore you mentioned. thank you so much :)
I had the same issue... I just deleted node_modules and installed it again :)
yarn -> 1.22.09
---
"react-native": "0.72.7
"react-native-keychain": "^8.1.2"
You can try reinstalling pods and verify podfile.lock contains a link to react-native-keychain nodemodule
same issue, non of the solutions above worked
yea same here, I was using expo and made the switch to secureStore. Would recommend!
Had same issue... (for IOS) make sure you add keychain manually in xcode at the 'capabilities' section and run pod install in the ios folder after installing the package. rebuild your project and it should work. you might experience crash in the app after saving the first time, but make sure your app allows and accepts keychain.
same issue, non of the solutions above worked. Works fine on iOS but not on Android. I am not using expo. Uninstalling the app and re-building did not fix the issue
"react-native": "^0.73.9", "react-native-keychain": "^9.2.2",
I had the same issue.I uninstalled the app and then build it again.The error got resolved after the new build.
Some more context for my issue: I am not using expo. This also does not happen on iOS. When I run my app initially, react native keychain works fine. However, if I close the app and re-open it again, I get this error when calling setGenericPassword and getGenericPassword.
Tried replicating in a bare react native app and was unable to do so.
Version:
"react-native-keychain": "^8.1.1"
"react-native": "0.71.3"
Expected behavior: Set token, get token, display token Actual behavior:Relevant code: