Giter Site home page Giter Site logo

react-native-leancloud's Introduction

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:

  • Right click Libraries
  • Add Files to [your project's name]
  • Go to node_modules/react-native-leancloud/ios
  • Add the .xcodeproj file

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

  • Add the libRNLeanCloud.a from the deviceinfo project to your project's Build Phases โžœ Link Binary With Libraries
  • Click .xcodeproj file you added before in the project navigator and go the Build Settings tab. Make sure All is toggled on (instead of Basic).
  • Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React
  • Mark both as recursive (should be OK by default).

Run your project (Cmd+R)

Android

With React Native 0.29+

  • in MainApplication.java:
+ 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:

  • in MainActivity.java:
+ 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

  • in info.plist
+   <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,
});

react-native-leancloud's People

Contributors

nihgwu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.