I'm using intent to start my React-Native app, and I'm trying to find out how to get the variables I put on my intent in the react native code. Is this possible from within react-native or do I have to write some java code to get it?
the code I use to start the app :
Intent intent = new Intent(this, MainActivity.class);
Intent.putExtra("alarm",true);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Thanks!
You can pass initial props as a bundle to the third parameter in the
startReactApplication
method, like so:See this answer for more details: https://stackoverflow.com/a/34226172/293280
Try this to get Intent params at react-native app.
In my native App, I use this code:
In react-native project, my MainActivity.java
In my first Container I get the param in this.props
The complete example I found here: http://cmichel.io/how-to-set-initial-props-in-react-native/