Adds the app to share menu, so it can be launched from share menu and receive data from other apps
npm install react-native-file-share-intent:star: :star: :star: :star:
| Android | Ios |
| :---: | :---: |
| !android text | !android text |
Adds the application to the share intent of the device, so it can be launched from other apps and receive data from them
* Install the module
``bash`
npm i --save react-native-file-share-intent
At the command line, in the project directory: only For Android and in ios use Manual installation
`bash`
react-native link
App.js
`javascript
import React, { Component } from 'react';
import {Text,View} from 'react-native';
import RNFileShareIntent from 'react-native-file-share-intent';
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
fileUrl: null,
};
}
componentDidMount() {
if(RNFileShareIntent){
RNFileShareIntent.getFilepath((url) => {
this.setState({ fileUrl: url });
})
}
}
render() {
var uri = this.state.fileUrl;
return (
);
}
}
`
Share.js in the Root Folder
`javascript
import React, { Component } from 'react';
import { View, Text, AppRegistry, StyleSheet, Button } from 'react-native';
import RNFileShareIntent from 'react-native-file-share-intent';
export default class Share extends Component {
constructor(props) {
super(props);
this.state = {
sharedText: null
};
}
componentDidMount() {
var that = this;
RNFileShareIntent.getFilePath((text) => {
that.setState({ sharedText: text });
})
}
render() {
var url = this.state.sharedText;
return (
title="open With Other App"
color="#841584"
onPress={() => RNFileShareIntent.openURL(url)}
/>
title="Close Extension"
color="#841584"
onPress={() => RNFileShareIntent.close()}
/>
)
}
}
const styles = StyleSheet.create({
text: {
color: 'black',
backgroundColor: 'white',
fontSize: 30,
margin: 80
}
});
AppRegistry.registerComponent('Share', () => Share);
``
Or check the "example" directory for an example application.



Sponsored and developed by Ajith A B