@qudian_mobile/qd-react-native-storage
v0.1.2
Published
## Getting started
Downloads
4
Keywords
Readme
qd-react-native-storage
Getting started
$ npm install @qudian_mobile/qd-react-native-storage --save
Mostly automatic installation
$ react-native link @qudian_mobile/qd-react-native-storage
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜@qudian_mobile/qd-react-native-storage
and addRNStorage.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNStorage.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.qudian.react_storage.RNStoragePackage;
to the imports at the top of the file - Add
new RNStoragePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':qd-react-native-storage' project(':qd-react-native-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@qudian_mobile/qd-react-native-storage/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':qd-react-native-storage')
Usage
React层的存取
import RNStorage from 'qd-react-native-storage';
// 存
RNStorage.setStringForKey('test_string', 'test');
// 取
RNStorage.stringForKey('test').then((res) => {
});
Native层的存取
Android
// 存
RNStorageModule.setStringForKey("test_string", "test");
// 取
RNStorageModule.getString("test");