Skip to content

moorinl/react-native-share-actions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React-native-share-actions

React Native show share actions for Android and iOS.

npm version

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 ${result.method}`);
    }
  } catch (error) {
    console.error(error);
  }
}
var ShareActions = require('react-native-share-actions');

function handlePressShare() {
  ShareActions.share({
    url: 'http://www.example.com',
    message: 'This is a message',
    subject: 'Example'
  }, 'Share URL')
    .then(function(result) {
      if (result.success) {
        console.log(`Shared via ${result.method}`);
      }
    })
    .catch(function(error) {
      console.error(error);
    });
}

About

React Native show share actions for Android and iOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published