React-native-keychain: TypeError: Cannot read property 'setGenericPasswordForOptions' of undefined

Created on 9 Mar 2017  路  16Comments  路  Source: oblador/react-native-keychain

I use Keychain as basic example:

      .setGenericPassword('myUserName', 'myPassword')
      .then(() => {
        console.log('Credentials saved successfully!');
      });

but this error happens:

screen shot 2017-03-09 at 22 13 24
Do you have any idea why ?

Most helpful comment

Had this problem, was solved by running

react-native link
react-native run-ios # or run-android

read more here

All 16 comments

on what platform do you have the issue? have you tried following the manual installation instructions to check everything's set up properly? are you using the right package version for your RN version? (there was breaking change for in 0.40 I believe)

@leizard Yes I'm getting a similar error after upgrading to the current version in order to accommodate the breaking changes introduced by RN 0.40

Got a similar error. After updating to RN 0.42.3 and restarting the app with the commands

react-native run-android
react-native start --reset-cache

it is working properly. Was it the restart or the update, i don't know.

I had a similar error, but it was fixed when I restarted using react-native run-ios. My guess is the simulator didn't understand that the new library was linked.

having the same problem. Restart and update didn't work.

using:

    "react-native": "0.43.4",
    "react-native-keychain": "^1.2.0",

Had this problem, was solved by running

react-native link
react-native run-ios # or run-android

read more here

Running this version combo:
"react-native": "0.43.2",
"react-native-keychain": "^2.0.0-rc",

But the issue still existing, after running:
react-native link
react-native run-ios

Any tips for a working combo of RN and RNK? Thanks much!

I am getting same error when calling setGenericPasswordForOptions,My RN version is

             "react-native": "0.46.4",
    "react-native-keychain": "2.0.0-rc",

But the issue still existing, after running:
react-native link
react-native run-ios.Please give any tips for solving problem

Unable to test to confirm if this will help, but generally my debug process would be to:

  • Kill anything running (the window that run-ios opens, the simulator etc.)
  • Delete node_modules run npm install again
  • Create a new RN project and copy code over and try again
  • Update to newest react-native version (don't forget that if you do this you'll probably want to init your entire project again)
  • Node also caches some stuff in your home directory, if after all of the above it's still not working, it might be worth deleting the cached files and retrying the step all over again.

@wmak ,Thanks for the replay, I had tried all these steps, But getting same error

I am also having the same error.
my RN version is
"react-native": "^0.46.1", "react-native-keychain": "^2.0.0-rc",

  • I linked my files with react-native link and rnpm link react-native-keychain.
  • Went to Xcode to change my keychain settings.
  • I also changed import method to import * as Keychain from 'react-native-keychain';
  • I did reset my cache
    ..... i am using npm run ios where ios is react-native-scripts ios instead of using react-native run-ios
    ...none of the above i did helped....
    I don't know if the issue happens because i didn't use index.ios.js as my entry file... hope someone finds the solution.

hello, please check my first comment, especially the part about manual installation (try to install manually)

The only thing that helped me is rebuilding project via Android Studio's _Build_ -> _Rebuild project_ menu item.

Hey @oblador. I think this issue should be closed, it seems to be more a config issue on the client end rather than an issue with this library.

this error goes away after a clean rebuild: rm -rf ios/build && react-native run-ios

@wmak Yup, closing 馃憤

Was this page helpful?
0 / 5 - 0 ratings