Code Monkey home page Code Monkey logo

react-native-instagram-share-android's Introduction

react-native-instagram-share-android

A React Native module that allows you to share image with instagram for android.

Installation

npm i --save react-native-instagram-share-android

Link it to your android project

Manual linking

In android/settings.gradle

...
include ':react-native-instagram-share-android', ':app'
project(':react-native-instagram-share-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-instagram-share-android/android')

In build.gradle

...
dependencies {
    ...
    compile project(':react-native-instagram-share-android')
}

In MainActivity.java

...
import android.app.Activity;              <-------- Add this line

public class MainActivity extends ReactActivity {
  public static Activity activity;        <-------- Add this line

    @Override
    protected String getMainComponentName() {
       activity = this;                   <-------- Add this line
        ...
    }
}

Register module (in MainApplication.java)

Add the following import statement:

import bhumi.customInstagramShare.CustomInstagramSharePackage;   <---- Add this line

...and then add CustomInstagramSharePackage to exported package list (MainApplication.java#getPackages):

public class MainApplication extends Application implements ReactApplication {
    // (...)

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new CustomInstagramSharePackage(MainActivity.activity)        <------- Add this line
      );
    }
}

Usage

import React, {
  AppRegistry,
  Component,
} from 'react-native';

var CustomInstagramShare = require('react-native-instagram-share-android');

class InstagramShareApp extends Component {
  shareWithInstagram(){
    let mediaPath = '--------- your file path -----------';
    CustomInstagramShare.shareWithInstagram(mediaPath,function(result){
        alert(result);
      });
  }

  render() {
    return (
      <View style={{flex : 1,justifyContent : 'center'}}>
        <TouchableHighlight onPress={() => this.shareWithInstagram()} style={{backgroundColor : 'black',borderRadius : 5,margin : 5,height : 50,alignItems : 'center',justifyContent : 'center'}}>

          <Text style={{color : 'white'}}>Share With Instagram</Text>

        </TouchableHighlight>
      </View>
    );
  }
}

Example

Try the included InstagramShare example yourself:

git clone https://github.com/bhoomika911/react-native-instagram-share-android.git
cd react-native-instagram-share-android/Examples/InstagramSharing
npm install
react-native run-android

Properties

mediaPath

Media File Path to share with instagram.

react-native-instagram-share-android's People

Contributors

bhoomika911 avatar carobeta avatar

Watchers

James Cloos avatar Maximiliano Techera avatar Gonzalo Gutiérrez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.