react-native-open-native-screen v0.0.4
react-native-open-native-screen
Getting started
$ npm install react-native-open-native-screen --save
Mostly automatic installation
$ react-native link react-native-open-native-screen
Manual installation
iOS
In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name]Go to
node_modules➜react-native-open-native-screenand addOpenNativeScreen.xcodeprojIn XCode, in the project navigator, select your project. Add
libOpenNativeScreen.ato your project'sBuild Phases➜Link Binary With LibrariesRun your project (
Cmd+R)<
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
Add
import com.reactlibrary.OpenNativeScreenPackage;to the imports at the top of the fileAdd
new OpenNativeScreenPackage()to the list returned by thegetPackages()method
- Append the following lines to
android/settings.gradle:
include ':react-native-open-native-screen'
project(':react-native-open-native-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-open-native-screen/android')- Insert the following lines inside the dependencies block in
android/app/build.gradle:
compile project(':react-native-open-native-screen')Usage
import OpenNativeScreen from "react-native-open-native-screen";
OpenNativeScreen.startActivity(activityName, intentParameters);Start Android activity
for start Android activity you can startActivity(nameOfActivity, paramaters, promise) method like below:
OpenNativeScreen.startActivity("com.open_screen_test.SecondActivity", {
id: 12345,
grade: 19.25,
isPassed: true,
name: "react native open native screen"
})
.then(response => {
console.log("response is: ", response);
})
.catch(error => {
console.log("error is: ", error);
});you can access to parameters in your activity (in this example second activity) like below:
Intent intent = getIntent();
double id = intent.getDoubleExtra("id", 0);
double grade = intent.getDoubleExtra("grade", 0d);
boolean isPassed = intent.getBooleanExtra("isPassed", false);
String name = intent.getStringExtra("name");support parameters type:
- Number: you can access to all number type like int, float, double in getDoubleExtra in second activity
- String
- Boolean
- Array (coming soon)
- HashMap or Object (comming soon)
Tips
To find activity name you have two choice:
- name_of_application_package + activity_name
- In android studio right click on class name and click on copy reference