All Projects β†’ doefler β†’ React Native Social Share

doefler / React Native Social Share

Licence: mit
Use the iOS and Android native Twitter and Facebook share popup with React Native https://github.com/doefler/react-native-social-share

Projects that are alternatives of or similar to React Native Social Share

Play Pac4j
Security library for Play framework 2 in Java and Scala: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 375 (-7.41%)
Mutual labels:  twitter, facebook
Laravel Social Auto Posting
🌈Laravel social auto posting
Stars: ✭ 306 (-24.44%)
Mutual labels:  twitter, facebook
Timeliner
In general, Timeliner obtains items from data sources and stores them in a timeline.
Stars: ✭ 2,911 (+618.77%)
Mutual labels:  twitter, facebook
node-facebook-twitter-google-github-login
Node, Express, Mongoose, Passport, Facebook, Twitter, Google and Github Authentication (Login)
Stars: ✭ 31 (-92.35%)
Mutual labels:  facebook, twitter
Socialbox Termux
SocialBox is a Bruteforce Attack Framework [ Facebook , Gmail , Instagram ,Twitter ] , Coded By Belahsan Ouerghi Edit By init__0 for termux on android
Stars: ✭ 324 (-20%)
Mutual labels:  twitter, facebook
oauth
Allow users to log in with GitHub, Twitter, Facebook, and more!
Stars: ✭ 21 (-94.81%)
Mutual labels:  facebook, twitter
Socialmanagertools Gui
πŸ€– πŸ‘» Desktop application for Instagram Bot, Twitter Bot and Facebook Bot
Stars: ✭ 293 (-27.65%)
Mutual labels:  twitter, facebook
gobo
πŸ’­ Gobo: Your social media. Your rules.
Stars: ✭ 87 (-78.52%)
Mutual labels:  facebook, twitter
Sockethub
A protocol gateway for the Web.
Stars: ✭ 329 (-18.77%)
Mutual labels:  twitter, facebook
Social Media Profiles Regexs
πŸ“‡ Extract social media profiles and more with regular expressions
Stars: ✭ 324 (-20%)
Mutual labels:  twitter, facebook
social-button
Social Buttons as Web Components
Stars: ✭ 17 (-95.8%)
Mutual labels:  facebook, twitter
Miranda Ng
Miranda NG: Next Generation of Miranda IM
Stars: ✭ 341 (-15.8%)
Mutual labels:  twitter, facebook
stay-productive
Remove feed from Facebook, Twitter and Linkedin... To stay productive !
Stars: ✭ 15 (-96.3%)
Mutual labels:  facebook, twitter
Data-mining-python-script
It contain various script on web crawling/ data mining of social web(RSS,facebook,twitter,Linkedin)
Stars: ✭ 24 (-94.07%)
Mutual labels:  facebook, twitter
cakephp-social-share
CakePHP link generator for sharing content on social networks
Stars: ✭ 30 (-92.59%)
Mutual labels:  facebook, twitter
Embera
A Oembed consumer library, that gives you information about urls. It helps you replace urls to youtube or vimeo for example, with their html embed code. It has advanced features like offline support, responsive embeds and caching support.
Stars: ✭ 268 (-33.83%)
Mutual labels:  twitter, facebook
Hackathon Starter Kit
A Node-Typescript/Express Boilerplate with Authentication(Local, Github, Facebook, Twitter, Google, Dropbox, LinkedIn, Discord, Slack), Authorization, and CRUD functionality + PWA Support!
Stars: ✭ 242 (-40.25%)
Mutual labels:  twitter, facebook
node-htmlmetaparser
A `htmlparser2` handler for parsing rich metadata from HTML. Includes HTML metadata, JSON-LD, RDFa, microdata, OEmbed, Twitter cards and AppLinks.
Stars: ✭ 44 (-89.14%)
Mutual labels:  facebook, twitter
Hybridauth
Open source social sign on PHP Library. HybridAuth goal is to act as an abstract api between your application and various social apis and identities providers such as Facebook, Twitter and Google.
Stars: ✭ 3,223 (+695.8%)
Mutual labels:  twitter, facebook
Socialreaper
Social media scraping / data collection library for Facebook, Twitter, Reddit, YouTube, Pinterest, and Tumblr APIs
Stars: ✭ 338 (-16.54%)
Mutual labels:  twitter, facebook

React Native Social Share

Use the built-in share view from iOS and Android to let the user share on Facebook and Twitter. It will use the user's existing account without having to get new authorizations. You can even preset text, image and link for the share view.

In other words a React Native wrapper for the SLComposeViewController

Support for Android

27 Feb 2017 - @minhtule has made improvements to sharing on Android

10 Feb 2017 - @Jberlinsky has added support for Android

Let me know how it works.

Animation

Getting started

  1. npm install react-native-social-share --save
  2. react-native link
  3. In XCode, in the project navigator right click Libraries ➜ Add Files to [your project's name]
  4. Go to node_modules ➜ react-native-social-share➜ iOS and add KDSocialShare.h and KDSocialShare.m
  5. Go to your project's Build Phases ➜ Link Binary With Libraries phase
  6. Add Social.framework to ➜ Link Binary With Libraries build phase of your project (click the '+' and search for 'social').
  7. Add 'LSApplicationQueriesSchemes' key (Type: Array) with items (Type: String) 'fb' and 'twitter' to Info.plist of your project
  8. Run your project (Cmd+R)

Now you can implement the share popups in your react native code.

Example of implementation

First you should make the native implementation available in the react code by inserting the following line in the top of the file

import {
  shareOnFacebook,
  shareOnTwitter,
} from 'react-native-social-share';

After doing that you will be able to popup the share views from your own functions. I made two examples below, one for Facebook and one for Twitter

  tweet : function() {

    shareOnTwitter({
        'text':'Global democratized marketplace for art',
        'link':'https://artboost.com/',
        'imagelink':'https://artboost.com/apple-touch-icon-144x144.png',
        //or use image
        'image': 'artboost-icon',
      },
      (results) => {
        console.log(results);
      }
    );
  },

  facebookShare : function() {

    shareOnFacebook({
        'text':'Global democratized marketplace for art',
        'link':'https://artboost.com/',
        'imagelink':'https://artboost.com/apple-touch-icon-144x144.png',
        //or use image
        'image': 'artboost-icon',
      },
      (results) => {
        console.log(results);
      }
    );
  },

The two implementations take the following parameters

  • shareOnFacebook(options [object], callback [function])
  • shareOnTwitter(options [object], callback [function])

IMPORTANT Both the options object and the callback function needs to be set. The options object can be empty though if you do not want to preset any of the possible options.

Options

The options object lets you pre-populate the share view for the user. You can use the following parameters:

Parameter Desciption
text Sets the initial text of the message on the SLComposeViewController instance.
imagelink Adds an image file from the given publicly available URL as attachments to the message.
image Adds an image file from the xcode image assets. image takes priority over imagelink. Only one out of two will load.
link Adds a URL to the message. The method automatically handles the URL shortening.

At least the text or link parameter must be specified

Special Case: Facebook on Android

Due to various known problems with Facebook's implementation of Android Intents, sharing with Facebook on Android can only be done in two ways:

  1. If the user has the Facebook application installed, and the text parameter is provided; or
  2. If the link parameter is provided.

Only one of the link or text parameter can be passed to the shareWithFacebook method on Android devices. Image parameters are ignored entirely.

We recommend using the official Facebook SDK to perform more complex sharing operations on Android.

Callback

The callback function runs when the native environment has information for the react environment. Note that some callbacks are only available on iOS due to platform limitations

Callback Desciption iOS Android
"success" Native call made by the viewController - SLComposeViewControllerResultDone – The user sent the composed message by touching the Send button. Yes No
"cancelled" Native call made by the viewController - SLComposeViewControllerResultCancelled – The user cancelled the composition session by touching the Cancel button. Yes No
"not_available" The selected service eg. Facebook, is not available. This can be because the user has not signed in to Facebook on the device or maybe there is no internet access. Yes No (Android functionality falls back to web views)
"missing_link_or_text" Neither the link nor text parameter was provided Yes Yes

You can use these callbacks to present alerts to the user. For example tell the user to login to a certain service.

The full example code

'use strict';

var React = require('react-native');
var {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableHighlight,
} = React;

import {
  shareOnFacebook,
  shareOnTwitter,
} from 'react-native-social-share';


var ReactNativeSocialShare = React.createClass({

  tweet : function() {

    shareOnTwitter({
        'text':'Global democratized marketplace for art',
        'link':'https://artboost.com/',
        'imagelink':'https://artboost.com/apple-touch-icon-144x144.png',
        //or use image
        'image': 'artboost-icon',
      },
      (results) => {
        console.log(results);
      }
    );
  },

  facebookShare : function() {

    shareOnFacebook({
        'text':'Global democratized marketplace for art',
        'link':'https://artboost.com/',
        'imagelink':'https://artboost.com/apple-touch-icon-144x144.png',
        //or use image
        'image': 'artboost-icon',
      },
      (results) => {
        console.log(results);
      }
    );
  },


  render: function() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Twitter and Facebook share
        </Text>

        <Text style={styles.instructions}>
          Try tapping one of the buttons
        </Text>

        <View style={styles.seperator}/>

        <TouchableHighlight onPress={this.tweet}>
          <View style={{alignItems: 'center',justifyContent:'center', width: 150, height: 50,backgroundColor:'#00aced'}}>
           <Text style={{color:'#ffffff',fontWeight:'800',}}>Share on Twitter</Text>
          </View>
        </TouchableHighlight>

        <View style={styles.seperator}/>

        <TouchableHighlight onPress={this.facebookShare}>
          <View style={{alignItems: 'center',justifyContent:'center', width: 150, height: 50,backgroundColor:'#3b5998'}}>
           <Text style={{color:'#ffffff',fontWeight:'800',}}>Share on Facebook</Text>
          </View>
        </TouchableHighlight>
      </View>


    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  seperator:{
    marginBottom: 20
  }
});

AppRegistry.registerComponent('ReactNativeSocialShare', () => ReactNativeSocialShare);

Done

Screenshot

Who is using it

Your contributions and suggestions are welcome.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].