GithubHelp home page GithubHelp logo

tsyeyuanfeng / react-native-cordova Goto Github PK

View Code? Open in Web Editor NEW

This project forked from remobile/react-native-cordova

0.0 2.0 0.0 60 KB

A cordova plugin bridge for react-native

License: MIT License

Java 59.01% JavaScript 11.38% Objective-C 28.96% Ruby 0.66%

react-native-cordova's Introduction

React Native Cordova (remobile)

A cordova plugin defines for react native on ios and android

Installation

npm install @remobile/react-native-cordova --save

Installation (iOS)

  • Drag RCTCordova.xcodeproj to your project on Xcode.

  • Click on your main project file (the one that represents the .xcodeproj) select Build Phases and drag libRCTCordova.a from the Products folder inside the RCTCordova.xcodeproj.

  • Look for Header Search Paths and make sure it contains $(SRCROOT)/../../../react-native/React as recursive.

  • In your project, Look for Header Search Paths and make sure it contains $(SRCROOT)/../../react-native-cordova/ios/RCTCordova.

  • then you can #import "CDVPlugin.h"

Installation (Android)

  • In Main project build.gradle
...
include ':react-native-cordova'
project(':react-native-cordova').projectDir = new File(settingsDir, '../node_modules/@remobile/react-native-cordova/android/RCTCordova')
  • In you project build.gradle
...
dependencies {
    ...
    compile project(':react-native-cordova')
}
  • then you can import com.remobile.cordova.* ;

Usage

IOS

#import "CDVPlugin.h"
...
@interface CustomClass : CDVPlugin
@end
...

@implementation CustomClass
RCT_EXPORT_MODULE(RCTCustomClass)
RCT_EXPORT_CORDOVA_METHOD(test);
...
- (void) test:(CDVInvokedUrlCommand *)command {
...
}
....
@end

Android

import com.remobile.cordova.*;
...
public class CustomClass extends CordovaPlugin {
...
    public CustomClass(ReactApplicationContext reactContext) {
            super(reactContext);
        }
...
    @Override
    public String getName() {
        return "Sqlite";
    }
    @ReactMethod
    public void test(ReadableArray args, Callback success, Callback error) {
        executeReactMethod("test", args, success, error);
    }
    ...
    public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
        if (action.equals("test")) {
            ....
            return true;
        }
        ....
        return false;
    }
}

Project List

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.