Skip to content

alenoir/react-native-boilerplate-bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-boilerplate-bridge

Boilerplate of React Native module for android

Installation

Installation on Android

Edit android/settings.gradle to declare the project directory:

include ':RNBridge', ':app'
project(':RNBridge').projectDir = new File(rootProject.projectDir, '../path/to/react-native-boilerplate-bridge/android')

Edit android/app/build.gradle to declare the project dependency:

dependencies {
  ...
  compile project(':react-native-boilerplate-bridge')
}

Edit android/app/src/main/java/.../MainActivity.java to register the native module:

...
import com.boilerplate.RNBridge.RNBridgePackage; // <-- New
...

public class MainActivity extends ReactActivity {
  ...
  @Override
  protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new RNBridgePackage() // <-- New
    );
  }

For older MainActivity.java templates, edit as follows:

...
import com.boilerplate.RNBridge.RNBridgePackage; // <-- New
...

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
  ...
    @Override
  protected void onCreate(Bundle savedInstanceState){
    ...
    mReactInstanceManager = ReactInstanceManager.builder()
      .setApplication(getApplication())
      ...
      .addPackage(new MainReactPackage())
      .addPackage(new RNBridgePackage()) // <-- New
      ...
  }

Basic usage

// Import the react-native-boilerplate-bridge module
var RNBridge = require('../lib/react-native-boilerplate-bridge');

// init
var bridge = new RNBridge();

// Callback

bridge.callbackExample(function(result) {
  console.log('--- RNBridge ---', result);
});

About

Boilerplate for react-native bridge

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published