GithubHelp home page GithubHelp logo

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

react-native-cordova's People

Contributors

fov42550564 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-native-cordova's Issues

[Android] Compatibility issue with react-native-navigation

Hi, first of all thanks for your plugins, i've been using them in an application i'm developing.
Unfortunately i'm having an issue with the android version (iOS version works very well).

I was trying to implement the react-native-camera and couldn't get the camera open. At first i thought there was a problem with react-native-camera, but after some debugging i got this:

java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode
  at android.support.v4.app.BaseFragmentActivityGingerbread.checkForValidRequestCode(BaseFragmentActivityGingerbread.java:88)
  at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:856)
  at com.remobile.cordova.CordovaInterface.startActivityForResult(CordovaInterface.java:62)

I'm using a component called react-native-navigation (to implement fully native navigation in the app) and this error appear because you need to do some changes to the android skeleton and your main activity extends a class that extends android.support.v4.app.FragmentActivity (originally the MainActivity extends android.app.Activity). And in FragmentActivity startActivityForResult can't accept requestCode higher than 65535.

I've solved the error by editing CordovaPlugin.java and changing RESULT_STEP to a lower level value. But originally that value is 1000000, is there any reason for that?

Thanks for sharing your hard work!

Missing libRTCordova.a, ERROR `new NativeEventEmitter()` requires a non-null argument.

6 years passed since last release happened. I hope someone will see this.
I'm running into problem setting it up with newest ReactNative 0.71.4 along with indoorAtlas library.

After adding this into package.json, which chas @remobile/react-native-cordova as a dependency, so I'm installing ver 1.1.1 as well of it.

"react-native-indooratlas": "git+https://github.com/IndoorAtlas/cordova-plugin.git#react-native",

and then on mounting component I initialize IndoorAtlas SDK I go this errors:

 ERROR  Invariant Violation: `new NativeEventEmitter()` requires a non-null argument., js engine: hermes
 LOG  Running "MobileAppName" with {"rootTag":1,"initialProps":{}}
 ERROR  Invariant Violation: "MobileAppName" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes

Thing is that those errors are not connected to the hermes itself, it looks like one of those packages broke the build pipe.
I tried to go through README.md installation process but libRCTCordova.a file is missing under xcodeproj.

Any thoughts?

error building

JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Cannot evaluate module react-native-cordova : Configuration with name 'default' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Plugin for web view

Hi,
I want to show the cordova pages inside the react-native app. I was planning to do by using the cordova webview and then rendering it in react-native. Can anybody help?

podSpec file not found

Please add this RCTCordova.podspec file inside your ios path

require 'json'

package = JSON.parse(File.read(File.join(dir, '../package.json')))

Pod::Spec.new do |s|
s.name = "RCTCordova"
s.version = package['version']
s.summary = package['description']

s.homepage = package['homepage']
s.authors = package['author']
s.license = package['license']
s.platform = :ios, "9.0"

s.source = { :git => '' }
s.source_files = '/*.{h,m}'
s.preserve_paths = '
/*.{h,m}'

s.dependency 'React-Core'
end

No visible @interface for 'CDVPluginResult' declares the selector 'setKeepCallbackAsBool:'

Hi,

I have one custom cordova plugin made by client developers, which i need to be integrated into my react-native application for IOS.

I have used your component and also added the cordova class in my project, but i get the above mentioned error i.e. No visible @interface for 'CDVPluginResult' declares the selector 'setKeepCallbackAsBool:'

Following is the code of cordova class .m file:

#import "CordovaHaxeBridge.h"
#import "mmsne_api.h"

NSString * callbackId;
CordovaHaxeBridge * instance;

void on_event(NSString * name, NSString * data) {
    //NSLog(@"Event %@ : %@",name,data);
    if (instance && callbackId)
    @autoreleasepool {
        NSDictionary * evt = [NSDictionary dictionaryWithObjectsAndKeys:name,@"name",data,@"data", nil];
        CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
                                                messageAsDictionary:evt];
       [result setKeepCallbackAsBool:YES];
        [instance.commandDelegate sendPluginResult:result callbackId: callbackId];
    }
    else
      NSLog(@"EVENT NOT PASSED ON: %@",name);

    //delete name, data;
}

@implementation CordovaHaxeBridge {}
RCT_EXPORT_MODULE(RCTCordovaHaxeBridge)
RCT_EXPORT_CORDOVA_METHOD(call);

- (void)pluginInitialize {
    NSLog(@"Initing MMSNE Cordova plugin");
    init_mms(&on_event);
    instance = self;
}

- (void)eventer:(CDVInvokedUrlCommand *)command {
    NSLog(@"Eventer initialized");
    callbackId = command.callbackId;
}


- (void)call:(CDVInvokedUrlCommand *)command {
    NSString * fname = [command.arguments objectAtIndex: 0];
    NSString * args = [command.arguments objectAtIndex: 1];
    //NSLog(@"OC PRE Call %@: %@",fname,args);
    call_haxe(fname,args);
    //NSLog(@"OC POST Call %@",fname);

    //delete fname, args;

    CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

@end

I am getting error on the following line:

[result setKeepCallbackAsBool:YES];

Following is the code of .h file :

#import "CDVPlugin.h"
@interface CordovaHaxeBridge : CDVPlugin

- (void)call:(CDVInvokedUrlCommand*)command;
- (void)eventer:(CDVInvokedUrlCommand*)command;

@end

I have compared the code from the following url:
https://github.com/apache/cordova-ios/blob/master/CordovaLib/Classes/Public/CDVPluginResult.m

there are some functions which are not included in your class can you please explain the reason for same.

Error when building app (+)

There is an error when building app:

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':app'.

    Cannot evaluate module react-native-cordova : Configuration with name 'default' not found.

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.