A React Native module to show system Image chooser. Currently only supports Android.
npm i --save react-native-appvirality
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);
}
......
}
First import the module as follows:
import React from "react-native";
const {
NativeModules: {
AppviralityModule
}
} = React;