react-native-share-actions

0.1.0 • Public • Published

React-native-share-actions

React Native show share actions for Android and iOS.

This module uses ActionSheetIOS for iOS and a native bridge for Android.

Installation

npm install react-native-share-actions
react-native link

Android manual Installation

In your android/app/build.gradle add:

dependencies {
    compile project(':react-native-share-actions')
}

In your android/settings.gradle add:

include ':react-native-share-actions'
project(':react-native-share-actions').projectDir = file('../node_modules/react-native-share-actions/android')

In your MainApplication.java add:

import io.moori.rnshareactions.RNShareActionsPackage;
 
@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
    new MainReactPackage(),
    new RNShareActionsPackage() // Add the package here 
  );
}

Usage

import ShareActions from 'react-native-share-actions';
 
async function handlePressShare() {
  try {
    const result = await ShareActions.share({
      url: 'http://www.example.com',
      message: 'This is a message',
      subject: 'Example'
    }, 'Share URL');
 
    if (result.success) {
      console.log(`Shared via ${method}`);
    }
  } catch (error) {
    console.error(error);
  }
}

Package Sidebar

Install

npm i react-native-share-actions

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • robmoorman