Giter VIP home page Giter VIP logo

balarajendran / react-native-file-share-for-android Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 3.77 MB

react-native-file-share-for-android which helps to share files, videos, photos etc into react-native apps. you can use this package via installing the npm package

Home Page: https://www.npmjs.com/package/react-native-file-share-for-android

License: MIT License

Java 51.36% JavaScript 17.35% Ruby 5.29% Objective-C 22.92% Starlark 3.07%
react-native react-native-android react-native-file-share android hybrid-app react-native-android-component

react-native-file-share-for-android's Introduction

react-native-file-share-for-android

react-native-file-share-for-android which helps to share files, videos, photos etc into react-native apps. you can use this package via installing the npm package

Example

Clone this example folder https://github.com/BalaRajendran/React-native-file-share-for-android and run in your local system

git clone https://github.com/BalaRajendran/React-native-file-share-for-android
npm install
react-native run-android

Getting started

$ npm install react-native-file-share-for-android --save

Mostly automatic installation

$ react-native link react-native-file-share-for-android

Manual installation

iOS

Package not supported in IOS

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.ReactNativeFileShareForAndroid.ReactNativeFileShareForAndroidPackage; to the imports at the top of the file
  • Add new ReactNativeFileShareForAndroidPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:

    include ':react-native-file-share-for-android'
    project(':react-native-file-share-for-android').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-file-share-for-android/android')
    
  2. In android/app/src/main/AndroidManifest.xml in

    • Add MIME Type which you want to support in your app
    <activity
    ...
    >
    ...
       <intent-filter>
       <action android:name="android.intent.action.SEND" />
       <category android:name="android.intent.category.DEFAULT" />
       <data android:mimeType="*/*" /> //It can accept everything
       </intent-filter>
    </activity>
    
    • Some of the Specific Mime Types are:
    <data android:mimeType="text/plain" />
    <data android:mimeType="image/*" />
    <data android:mimeType="application/*" />
    <data android:mimeType="video/*" />
    
  3. Insert the following lines inside the dependencies block in android/app/build.gradle

  implementation project(':react-native-file-share-for-android')

Issues

If you are facing any issues, create Issues in Repository

preview

click to play preview

Watch the video

Usage

import React, { Component } from "react";
import { View, Text } from "react-native";
import ReactNativeFileShareForAndroid from "react-native-file-share-for-android";

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      url: ""
    };
  }

  componentDidMount() {
    if (ReactNativeFileShareForAndroid) {
      ReactNativeFileShareForAndroid.getFilepath(url => {
        this.setState({ url });
      });
    }
  }

  render() {
    return (
      <View>
        <Text>File Url : </Text>
        <Text>{this.state.url}</Text>
      </View>
    );
  }
}

RNReactNativeFileShareForAndroid;

react-native-file-share-for-android's People

Contributors

balajirpurplelslate avatar balarajendran avatar imgbotapp avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

react-native-file-share-for-android's Issues

npm package size

The npm distribution is currently over 110mb big, which is absolutly convoluting my node_modules folder. The install effectively doubled my total project size...

Please remove the examples and the public folder from the npm distribution, they do not belong on the npm!

You could consider having an extra repo, where you only show the examples. The linked repo to the npm and this repo should mirror one another and be the absolute same. No examples and no public folder,
You basically distribute hundrets of other npm packages within your npm package, since they are all in the build folder inside the examples folder in your npm package.

Besides that, I am currently in the process of extracting the relevant code from your package and really hope it works, since this has been a feature I am really looking forward to :)

Update:
Sadly, the package does not work.

I have followed all manual installation steps, but adding the implementation line to bui.dgradle threw errors:

FAILURE: Build failed with an exception.

What went wrong:
A problem occurred evaluating root project 'android'.
Could not find method implementation() for arguments [project ':react-native-file-share-for-android'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

also, the node_module package.json does point to the wrong folder location. It points to the following folder, which is not part of the package:

"_location": "/react-native-file-share-for-android",

I would advice you @BalaRajendran to create a clean react native installation and follow the manual installation steps yourself, since you will stumble upon the same errors I have.

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.