$ npm install @react-native-social-share/core --save
$ react-native link react-native-core
** Require: react-native-fbsdk
** Require: @react-native-social-share/twitter
** Require: @react-native-social-share/instagram
In your metro.config.js
module.exports = {
transformer: {
allowOptionalDependencies: true, // <-- Add this
},
}
import RNSocialShare from '@react-native-social-share/core';
RNSocialShare.shareLink("facebook", options);
shareLink(provider, options)
- provider: 'facebook' | 'twitter';
- options:
- link: string link to share
- description: string (optional)
- hashtag: string (optional) (Facebook and Twitter)
- peopleIds: string[] (optional) (Facebook only) people ids to tag
const options = {
link: "https://github.com/r0b0t3d/react-native-social-share",
description: "React Native Social Share",
peopleIds: "",
hashtag: "#sharelink",
};
RNSocialShare.shareLink("facebook", options);
Note: Instagram do not support share link
sharePhoto(provider, options)
shareVideo(provider, options)
- provider: 'facebook' | 'twitter' | 'instagram';
- options:
- localFile: string file to share
- hashtag: string (optional) (Facebook and Twitter)
- peopleIds: string[] (optional) (Facebook only) people ids to tag
import CameraRoll from '@react-native-community/
const localFile = "";
const uri = CameraRoll.save(localFile, { type: 'photo' });
const options = {
localFile: uri,
peopleIds: "",
hashtag: "#sharefile",
};
RNSocialShare.sharePhoto("facebook", options);
Notes: Facebook
and Instagram
app must be installed