Sending simple data to other applications using React Native on Android

I have two response applications: App 1 and App 2. Now I need to run application 2 from application 1, passing simple text data. In a study using this link from Android docs, I can trigger app 2 activity from app 1 with indentation,

Sample Opening App2 from App1

But the question is, can I transfer this data to the React Native screen of application 2. My App 2 has a dummy activity class for receiving indentation from other applications, but if there is a very neat approach without indenting, skip data between applications in React Native.

+4
source share
1 answer

App1 App2 (Android)

, App1

npm i react-native-send-intent

1:

 var SendIntentAndroid = require('react-native-send-intent');

SendIntentAndroid.sendText({
  title: 'Please share this text',
  text: 'Lorem ipsum dolor sit amet, per error erant eu, antiopam intellegebat ne sed',
  type: SendIntentAndroid.TEXT_PLAIN
});

2:

 // You can  specify arbitrary intent extras to be passed to the app
    SendIntentAndroid.openApp('com.App2', 
         {"App2PropData1": "just because", "App2PropData2": "Lorem ipsum dolor sit amet, per error erant eu, antiopam intellegebat ne sed"}).then((wasOpened) => {});

2

props

    export default class App extends Component {

    render() {
        console.log('App props', this.props);
        console.log('App2PropData1', this.props.App2PropData1);
        console.log('App2PropData2', this.props.App2PropData2);
        //...
    }
}
+2

Source: https://habr.com/ru/post/1695508/


All Articles