Home

Awesome

react-native-android-share

This fires off the default android share tray:

<img src="http://i.imgur.com/avnu4ir.png" width="150">

Installl

npm i react-native-android-share --save

Add it to your android project

...
include ':RNAndroidShare', ':app'
project(':RNAndroidShare').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-share')
...
dependencies {
  ...
  compile project(':RNAndroidShare')
}
import com.blueprintalpha.rnandroidshare.RNAndroidSharePackage;  // <--- import

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
  ......

  @Override
  protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new RNAndroidSharePackage(this) // <------ add this line to your MainActivity class
      );
  }

  ......

}
var React = require('react-native')
var {
  View,
  Text,
  TouchableHighlight,
  Image,
} = React
var AndroidShare = require('react-native-android-share');

var ShareButton = React.createClass({

  // this will open the share tray
  _showShareActionSheet(story) {
    var object = {subject: 'Story Title', text: 'Message Body'};
    AndroidShare.openChooserWithOptions(object, 'Share Story');
  },

  // render a simple button
  render() {
    return (
        <TouchableHighlight
         underlayColor='rgba(0,0,0,0)'
         resizeMode='cover'
         onPress={()=>this._showShareActionSheet(this.props.story)}>
            <Image source={require("../images/share.png")}
            width={45}
            height={45}
            style={{height:45, width:45}}/>
          </TouchableHighlight>);
    },
});

module.exports = ShareButton;

TODO

CONTACT

thayden@gmail.com with questions or pull requests