Home

Awesome

react-native-leancloud

a react native component for leancloud javascript-sdk

this component simply move the appId and appKey from the javascript file to native code as it's really easy to get those values from the js.bundle in released app.

Install

you have to install leancloud javascript-sdk first

npm install nihgwu/react-native-leancloud --save

Automatically link

With React Native 0.27+

react-native link react-native-leancloud

With older versions of React Native

You need rnpm (npm install -g rnpm)

rnpm link react-native-leancloud

Manually link

iOS

In XCode, in the project navigator:

In XCode, in the project navigator, select your project.

Run your project (Cmd+R)

Android

With React Native 0.29+

+ import com.liteneo.RNLeanCloud.RNLeanCloudPackage;

  public class MainApplication extends Application implements ReactApplication {
    //......

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
+         new RNLeanCloudPackage("your leancloud appId", "your leancloud appKey"),
          new MainReactPackage()
      );
    }
    
    ......
  }

With older versions of React Native:

+ import com.liteneo.RNLeanCloud.RNLeanCloudPackage;

  public class MainActivity extends ReactActivity {
    ......

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
+       new RNLeanCloudPackage("your leancloud appId", "your leancloud appKey"),
        new MainReactPackage()
      );
    }
  }

Configuration

iOS

+   <key>LeanCloudAppId</key>
+   <string>your leancloud appId</string>
+   <key>LeanCloudAppKey</key>
+   <string>your leancloud appKey</string>

Android

see Manually link for Android

Usage

import AV from 'leancloud-storage';
import RNLeanCloud from 'react-native-leancloud';

AV.init({
  appId: RNLeanCloud.appId,
  appKey: RNLeanCloud.appKey,
});