🔑 Keychain Access for React Native
Go to file
Joel Arvidsson 1cbf2445b5 Merge branch 'master' of https://github.com/oblador/react-native-keychain
Conflicts:
	index.ios.js
2015-07-19 13:38:54 +02:00
Enums Fixed KeychainAccessibilityEnum. 2015-05-29 18:27:35 +02:00
KeychainExample Bumped example to 0.7.0-rc.2. 2015-07-19 13:36:40 +02:00
RNKeychain.xcodeproj Added project structure. 2015-05-20 18:23:04 +02:00
RNKeychainManager Added generic password support. 2015-05-29 18:25:56 +02:00
.editorconfig Added first implementation. 2015-05-20 20:39:52 +02:00
.gitignore Added project structure. 2015-05-20 18:23:04 +02:00
LICENSE Initial commit 2015-05-20 17:33:48 +02:00
README.md RN 0.7.0 support. 2015-07-06 12:49:20 +02:00
index.ios.js RN 0.7.0 support. 2015-07-06 12:49:20 +02:00
package.json Released 0.2.2. 2015-07-06 12:40:55 +02:00

README.md

react-native-keychain

Keychain Access for React Native

Currently functionality is limited to just storing internet and generic passwords. Wider exposure of the underlying API coming.

Installation

  • $ npm install react-native-keychain
  • Right click on Libraries, select Add files to "…" and select node_modules/react-native-keychain/RNKeychain.xcodeproj
  • Select your project and under Build Phases -> Link Binary With Libraries, press the + and select libRNKeychain.a.

Usage

See KeychainExample for fully working project example.

var Keychain = require('react-native-keychain');

var username = 'zuck';
var password = 'poniesRgr8';

// Generic Password, service argument optional
Keychain
  .setGenericPassword(username, password)
  .then(function() {
    console.log('Credentials saved successfully!');
  });

Keychain
  .getGenericPassword()
  .then(function(credentials) {
    console.log('Credentials successfully loaded for user ' + credentials.username);
  });

Keychain
  .resetGenericPassword()
  .then(function() {
    console.log('Credentials successfully deleted');
  });

// Internet Password, server argument required
var server = 'http://facebook.com';
Keychain
  .setInternetCredentials(server, username, password)
  .then(function() {
    console.log('Credentials saved successfully!');
  });

Keychain
  .getInternetCredentials(server)
  .then(function(credentials) {
    console.log('Credentials successfully loaded for user ' + credentials.username);
  });

Keychain
  .resetInternetCredentials(server)
  .then(function() {
    console.log('Credentials successfully deleted');
  });

License

MIT © Joel Arvidsson 2015