You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.
Open up android/app/src/main/java/[...]/MainActivity.java
Add import com.reactnativecommunity.modules.share.RNSimpleSharePackage; to the imports at the top of the file
Add new RNSimpleSharePackage() to the list returned by the getPackages() method
Append the following lines to android/settings.gradle:
include ':react-native-simple-share'
project(':react-native-simple-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-simple-share/android')
Insert the following lines inside the dependencies block in android/app/build.gradle:
compile project(':react-native-simple-share')
Usage
importReact,{Component}from"react";import{View,Button}from"react-native";importSimpleSharefrom"react-native-simple-share";exportdefaultclassShareExampleextendsComponent{onShare=async()=>{try{constresult=awaitSimpleShare.share({message:
"React Native | A framework for building native apps using React"});if(result.action===SimpleShare.sharedAction){if(result.activityType){// shared with activity type of result.activityTypeconsole.log("result",result);}else{// sharedconsole.log("result",result);}}elseif(result.action===SimpleShare.dismissedAction){// dismissedconsole.log("dismissed");}}catch(error){console.log("error",error.message);}};render(){return(<Viewstyle={{backgroundColor: "white",flex: 1,justifyContent: "center",alignItems: "center"}}><Buttontitle="Share"onPress={this.onShare}>
Share
</Button></View>);}}