I was wondering how does one start up a React-Native application and have the data in the intent when the application is launched, so that I can reference it in one of my React-Native components?
I put this intent-filter under my MainActivity in the mainfest:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
and then in MainActivity.java:
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected Bundle getLaunchOptions() {
Intent intent = MainActivity.this.getIntent();
Bundle bundle = new Bundle();
bundle.putString("test", "Test Data");
return bundle;
}
};
}
and then I tried referencing the "test" field in my app.js of my React Native:
componentDidMount() {
console.log(this.props.test);
}
However, the this.props.test is undefined, but it's supposed to say "Test Data" since I put that in the bundle of the MainActivity.java.