rn-secure-storage
Advanced tools
Comparing version
37
index.js
@@ -0,29 +1,16 @@ | ||
import { NativeModules } from 'react-native'; | ||
import {Platform, NativeModules } from 'react-native'; | ||
const { RNSecureStorage } = NativeModules; | ||
const { RNRnSecureStorage } = NativeModules; | ||
const isIOS = Platform.OS === "ios"; | ||
export const set = (key, value) => { | ||
if (isIOS) { | ||
return RNRnSecureStorage.set(key, value) | ||
} else { | ||
return RNRnSecureStorage.set(key, value); | ||
} | ||
export const ACCESSIBLE = { | ||
WHEN_UNLOCKED: 'AccessibleWhenUnlocked', | ||
AFTER_FIRST_UNLOCK: 'AccessibleAfterFirstUnlock', | ||
ALWAYS: 'AccessibleAlways', | ||
WHEN_PASSCODE_SET_THIS_DEVICE_ONLY: 'AccessibleWhenPasscodeSetThisDeviceOnly', | ||
WHEN_UNLOCKED_THIS_DEVICE_ONLY: 'AccessibleWhenUnlockedThisDeviceOnly', | ||
AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY: | ||
'AccessibleAfterFirstUnlockThisDeviceOnly', | ||
ALWAYS_THIS_DEVICE_ONLY: 'AccessibleAlwaysThisDeviceOnly', | ||
}; | ||
export const get = (key) => { | ||
if (isIOS) { | ||
return RNRnSecureStorage.get(key) | ||
} else { | ||
return RNRnSecureStorage.get(key); | ||
} | ||
}; | ||
export const clear = (key) => { | ||
if (isIOS) { | ||
return RNRnSecureStorage.clearWithKey(key); | ||
} else { | ||
return RNRnSecureStorage.clearWithKey(key); | ||
} | ||
}; | ||
export default RNSecureStorage; |
{ | ||
"name": "rn-secure-storage", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Secure Storage for React Native (Android & iOS)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# react-native-rn-secure-storage | ||
## Getting started | ||
`$ npm install react-native-rn-secure-storage --save` | ||
### Mostly automatic installation | ||
`$ react-native link react-native-rn-secure-storage` | ||
### Manual installation | ||
#### iOS | ||
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]` | ||
2. Go to `node_modules` ➜ `react-native-rn-secure-storage` and add `RNRnSecureStorage.xcodeproj` | ||
3. In XCode, in the project navigator, select your project. Add `libRNRnSecureStorage.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` | ||
4. Run your project (`Cmd+R`)< | ||
#### Android | ||
1. Open up `android/app/src/main/java/[...]/MainActivity.java` | ||
- Add `import com.taluttasgiran.rnsecurestorage.RNRnSecureStoragePackage;` to the imports at the top of the file | ||
- Add `new RNRnSecureStoragePackage()` to the list returned by the `getPackages()` method | ||
2. Append the following lines to `android/settings.gradle`: | ||
``` | ||
include ':react-native-rn-secure-storage' | ||
project(':react-native-rn-secure-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-rn-secure-storage/android') | ||
``` | ||
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`: | ||
``` | ||
compile project(':react-native-rn-secure-storage') | ||
``` | ||
## Usage | ||
```javascript | ||
import RNRnSecureStorage from 'react-native-rn-secure-storage'; | ||
// TODO: What to do with the module? | ||
RNRnSecureStorage; | ||
``` | ||
# RNSecureStorage |
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
-100%33184
-69.55%17
-41.38%280
-3.45%3
-93.33%