Skip to content

Latest commit

 

History

History
83 lines (57 loc) · 1.77 KB

README.md

File metadata and controls

83 lines (57 loc) · 1.77 KB

react-native-appvirality

A React Native module to show system Image chooser. Currently only supports Android.

Installation

npm i --save react-native-appvirality

Add it to your android project

In android/settings.gradle

...

include ':react-native-appvirality'
project(':react-native-appvirality').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-appvirality/android')

In android/app/build.gradle

...

dependencies {
    ...

    compile project(':react-native-appvirality')
}

Register module (in MainActivity.java)

import android.content.Intent;  // <--- import
import io.scrollback.AppviralityPackage;  // <--- import

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
  ......

  private AppviralityPackage mChoosersPackage = new AppviralityPackage(this); // <------ create new instance

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mReactRootView = new ReactRootView(this);

    mReactInstanceManager = ReactInstanceManager.builder()
      .setApplication(getApplication())
      .setBundleAssetName("index.android.bundle")
      .setJSMainModuleName("index.android")
      .addPackage(new MainReactPackage())
      .addPackage(new AppviralityPackage(this)) // <------ add the package
      .setUseDeveloperSupport(BuildConfig.DEBUG)
      .setInitialLifecycleState(LifecycleState.RESUMED)
      .build();

    mReactRootView.startReactApplication(mReactInstanceManager, "ExampleApp", null);

    setContentView(mReactRootView);
  }

  ......

}

Usage

First import the module as follows:

import React from "react-native";

const {
  NativeModules: {
    AppviralityModule
  }
} = React;