Giter Club home page Giter Club logo

react-native-share's Introduction

react-native-share react-native-share npm version semantic-release

React Native Share, is a simple tool for sharing messages and files with other apps.

Getting started 🚀


If you are using react-native >= 0.7X and/or the new arch you just need to do a simple:

yarn add react-native-share

Or if are using npm:

npm i react-native-share --save

After that, we need to install the dependencies to use the project on iOS(you can skip this part if you are using this on Android).

Now run a simple: npx pod-install or cd ios && pod install. After that, you should be able to use the library on both Platforms, iOS and Android.

Then simply import:

import Share from 'react-native-share';

Share.open(options)
  .then((res) => {
    console.log(res);
  })
  .catch((err) => {
    err && console.log(err);
  });

Which you do something similar to this:

example-ios

Documentation

If you are using a older version of react-native or react-native-share, having any problem or want to know how use Share.open and other functions, please refer to our new docs and help us improve that.🚀

react-native-share's People

Contributors

bitshadow avatar buttershub avatar charpeni avatar ddereszewski avatar dependabot[bot] avatar enieber avatar estebanfuentealba avatar esutton avatar friederbluemle avatar g3r4n avatar gevgasparyan avatar hbarylskyi avatar jgcmarins avatar kaioduarte avatar kkbhav avatar lifuzu avatar luancurti avatar maryjenel avatar mateusandrade avatar mikehardy avatar oleksandr-dziuban avatar ralfnieuwenhuizen avatar sam1463 avatar semantic-release-bot avatar shubhamdeol avatar sibelius avatar sumedhtare avatar xliank avatar yeomann avatar ygorbarboza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-share's Issues

Feature request - Return selected share method to client

react-native ActionSheetIOS.showShareActionSheetWithOptions api returns the method used to share the item to the success callback, anyway to add this functionality to this library as well?

I'm not familiar with objective-c or Java so unfortunately it will be hard for me to provide a PR :(

I can do with some guidance too and try to get a PR with some help though..

Thanks

iOS: Facebook fields are not prepopulated, but Twitter fields are

Here's my code:

share() {
    var { url, title } = this.props,
        params = {
            share_text: `Check out this awesome thing.`,
            share_URL: url,
            title
        };

    RNShare.open(params,(e) => {
        console.log(e);
    });
}

On Twitter, it works:
img_4967

But on Facebook, they're empty. Also, the image doesn't post. Any ideas?
img_4968

Cannot read property shareSingle of undefined

In my Buttons, the onPress function throws the error I copied in the title. Any idea why? I imported Share at the top of my file like so: import Share, { ShareSheet, Button } from 'react-native-share';

<Button iconSrc={{ uri: EMAIL_ICON }} onPress={() => { this.onCancel(); setTimeout(() => { Share.shareSingle(Object.assign(shareOptions, { social: 'email', })); }, 300); }} > Email </Button>

Error Invalid directory /Users/node_modules/NativeModules

I get the following error when running on iOS.

Unable to resolve module NativeModules from ]...]/node_modules/react-native-share/index.ios.js: Invalid directory /Users/node_modules/NativeModules

I believe this is because of the way you load the NativeModule, maybe they changed something.

"message" field is ignored for Facebook

Hello, the module is great! Thanks for that.

However, I am not able to pass message to the facebook share dialog. Twitter accepts the value fine. I use shareSingle() method for the share purpose.

Is this the predicted behavior or the bug? If the first - could it be somehow improved?

_reactNative.NativeModules.RNShare.shareSingle error

Hi

i installed the library using npm and did react-native link.

when i try to do the share i get the following error:

Possible Unhandled Promise Rejection (id: 0):
Cannot read property 'shareSingle' of undefined
TypeError: Cannot read property 'shareSingle' of undefined

It seems like it cant find the native modules even though i did react-native link

any help?

Thanks
Chris

Error on Share Dialog open

[info][tid:com.facebook.react.JavaScript] { error: 
   { code: 'ENSCOCOAERRORDOMAIN257',
     message: 'The file “Mobiblog” couldn’t be opened because you don’t have permission to view it.',
     nativeStackIOS: 
      [ '0   Mobiblog                            0x0000000100106e68 RCTJSErrorFromCodeMessageAndNSError + 148',
        '1   Mobiblog                            0x0000000100106d94 RCTJSErrorFromNSError + 264',
        '2   Mobiblog                            0x000000010009ce5c __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.203 + 112',
        '3   Mobiblog                            0x000000010015599c -[RCTActionSheetManager showShareActionSheetWithOptions:failureCallback:successCallback:] + 880',
        '4   CoreFoundation                      0x00000001810f0a60 <redacted> + 144',
        '5   CoreFoundation                      0x0000000180fe8488 <redacted> + 284',
        '6   CoreFoundation                      0x0000000180fecdb0 <redacted> + 60',
        '7   Mobiblog                            0x000000010009e99c -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1684',
        '8   Mobiblog                            0x00000001000ec2cc -[RCTBatchedBridge _handleRequestNumber:moduleID:methodID:params:] + 712',
        '9   Mobiblog                            0x00000001000eb4f0 __33-[RCTBatchedBridge handleBuffer:]_block_invoke.452 + 1144',
        '10  libdispatch.dylib                   0x0000000100841a7c _dispatch_call_block_and_release + 24',
        '11  libdispatch.dylib                   0x0000000100841a3c _dispatch_client_callout + 16',
        '12  libdispatch.dylib                   0x00000001008474e4 _dispatch_main_queue_callback_4CF + 2096',
        '13  CoreFoundation                      0x00000001810a0d50 <redacted> + 12',
        '14  CoreFoundation                      0x000000018109ebb8 <redacted> + 1628',
        '15  CoreFoundation                      0x0000000180fc8c50 CFRunLoopRunSpecific + 384',
        '16  GraphicsServices                    0x00000001828b0088 GSEventRunModal + 180',
        '17  UIKit                               0x00000001862b6088 UIApplicationMain + 204',
        '18  Mobiblog                            0x000000010006fcd4 main + 124',
        '19  libdyld.dylib                       0x0000000180b668b8 <redacted> + 4' ],
     domain: 'NSCocoaErrorDomain' } }

on ios on Device and Simulator both.

Also on app launch I see this in logs:

2016-09-13 16:15:37.128 [warn][tid:main][RCTBatchedBridge.m:274] Class GenericShare was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2016-09-13 16:15:37.134 [warn][tid:main][RCTBatchedBridge.m:274] Class WhatsAppShare was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2016-09-13 16:15:37.135 [warn][tid:main][RCTBatchedBridge.m:274] Class GooglePlusShare was not exported. Did you forget to use RCT_EXPORT_MODULE()?

It should work as Bottom sheet.

I Have a scenario where i wanted to show share sheet on clicking button in child component. if i put share sheet in parent it show as bottom sheet, if i put the same in child. It show in the middle of screen where child components end.

Is there any workaround to acheive this.

How to install it on RN 0.20 for Android?

It appears that the MainActivity.java file has changed for ReactNative release 0.19 and 0.20 compared to the documentation in the README. I can't find the onCreate-method, so it is not clear how to add the package .addPackage(new RNSharePackage())?

not working on android - undefined is not an object

I followed the example in the readme (tried both manual installation and automatic) and no matter what I do, when I press the share button Share.open always fails with:
undefined is not an object (evaluating '_reactNativeShare2.default.open')

building on Ubuntu 14.04 64-bit and running on Android 5.0.1

android build failed

Could not compile settings file '/Users/.../android/settings.gradle'.

startup failed:
settings file '/Users/.../android/settings.gradle': 2: expecting EOF, found '=' @ line 2, column 73.
act-native-share').projectDir = new File
^

Possible Unhandled Promise Rejection (id: 0)

I'm trying to implement the simple sharing

import Share, {ShareSheet, Button} from 'react-native-share';

<TouchableHighlight onPress={() => {
     Share.open({
        title: "React Native",
        message: "Hola mundo",
        url: "http://facebook.github.io/react-native/"
      })
}}>
      <Text> Share </Text>
</TouchableHighlight>

But I got this error:

09-07 11:07:45.829 3037 5393 W ReactNativeJS: Possible Unhandled Promise Rejection (id: 0):
09-07 11:07:45.829 3037 5393 W ReactNativeJS: undefined is not an object (evaluating '_reactNative.NativeModules.RNShare.open')

Any advice ?

Peer dependency requirements

Hello,

I ran into peer dependency issues trying to install package in RN 0.12. Perhaps you may bump up version to a stable RN release. Thanks

'gplus' is not a valid social key

        sharesExtra.put("generic", new GenericShare(this.reactContext));
        sharesExtra.put("facebook", new FacebookShare(this.reactContext));
        sharesExtra.put("twitter", new TwitterShare(this.reactContext));
        sharesExtra.put("whatsapp",new WhatsAppShare(this.reactContext));
        sharesExtra.put("googleplus",new GooglePlusShare(this.reactContext));
        sharesExtra.put("email",new EmailShare(this.reactContext));

It appears it's 'googleplus' not 'gplus' as documentation shows, just a heads up.

React-Native-Share ignores set orientation

In the manifest.xml I have set the orientation of my application to be portrait.
android:screenOrientation="portrait"
But upon opening the RN-share dialog the app responds to the orientation of the device until the dialog is closed. This causes visual glitches in apps that are not responsively designed.

screen shot 2016-08-02 at 16 31 54

Issue using on Android

Followed the instructions and getting an error - undefined is not an object (evaluating '_reactNativeShare2.default.open')

How to use simple share success callback ?

Hello, i success to share through the whatsapp, but i don't know how to use the callback,
because i want use success callback to close my modal box. thanks very much.

Share.open(shareOptions);

ANDROID problem: Multiple dex files define Landroid/support/v7/appcompat/R$anim;

Using react-native: 0.29.0

Hey, I added the library to my project and now I'm getting an error when I try to the run app on android:

:app:dexDebug
Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:
Unknown source file : com.android.dex.DexException: Multiple dex files define Landroid/support/v7/appcompat/R$anim;
Unknown source file :   at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
Unknown source file :   at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
Unknown source file :   at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
Unknown source file :   at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Unknown source file :   at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
Unknown source file :   at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
Unknown source file :   at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
Unknown source file :   at com.android.dx.command.dexer.Main.run(Main.java:277)
Unknown source file :   at com.android.dx.command.dexer.Main.main(Main.java:245)
Unknown source file :   at com.android.dx.command.Main.main(Main.java:106)

:app:dexDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

This happened before with another library which had a dependency on android-play-servicies, but as far as I can see, this library does not have this issue, any idea on how to solve this?

Android builds failed

after npm install and react-native link, tried to install my android app but i got this error:
reactnative 0.34

Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:
Unknown source file : com.android.dex.DexException: Multiple dex files define Landroid/support/v7/appcompat/R$anim;
Unknown source file :   at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
Unknown source file :   at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
Unknown source file :   at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
Unknown source file :   at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Unknown source file :   at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
Unknown source file :   at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
Unknown source file :   at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
Unknown source file :   at com.android.dx.command.dexer.Main.run(Main.java:277)
Unknown source file :   at com.android.dx.command.dexer.Main.main(Main.java:245)
Unknown source file :   at com.android.dx.command.Main.main(Main.java:106)

:app:dexDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 2

'RCTBridgeModule.h' file not found

Hi, when I switch build configuration to 'Release', I get the following error:
'RCTBridgeModule.h' file not found

This is in Xcode, I'm trying to run on an actual device

Error while trying to display: view is not in the window hierarchy

Hey,
anyone faced issue while trying to display share:

 Warning: Attempt to present <UIActivityViewController: 0x14f8baf80> on <UIViewController: 0x14e7306e0> whose view is not in the window hierarchy!

After this warning share isn't visible.
I tried to call this in upper level of my app and it helped, but it isn't best solution.

I there any way to fix this? I am not familiar with native iOS.

Facebook sharing issue.

The only thing I can share via fb is a url. Other option, like message or title just not appears in share body.

:app:dexDebug error

:app:dexDebug
Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:
Unknown source file : com.android.dex.DexException: Multiple dex files define Landroid/support/v7/appcompat/R$anim;
Unknown source file : at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
Unknown source file : at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
Unknown source file : at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
Unknown source file : at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Unknown source file : at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
Unknown source file : at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
Unknown source file : at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
Unknown source file : at com.android.dx.command.dexer.Main.run(Main.java:277)
Unknown source file : at com.android.dx.command.dexer.Main.main(Main.java:245)
Unknown source file : at com.android.dx.command.Main.main(Main.java:106)

Can't find Wechat sharing button, any reason why?

Hello,

thank you for this great component (cross platform 👍 ),

is there any reason why Wechat does not appear in the sharing option (for ios) but appears in Android? As I understand it's possible to exclude some application to show up in the list, but how to add one?

Cheers.

NativeModules error on iOS in rn 0.16.0

Unable to resolve module NativeModules from projectdirectory/node_modules/react-native-share/index.ios.js: Invalid directory /Users/node_modules/NativeModules

RNShare.open got 1 arguments, expected 2

I'm getting this weird error when triggering Share.open function with these arguments:

Share.open({
        url:          'www.google.es',
        message:      'Message',
        title:        'Share',
        subject:      'Subject',
      });

I attach the "red screen" error alert from React Native:

screenshot_2016-09-01-12-58-35

Push changes to NPM

It seems like some of the latest changes haven't been pushed to NPM - would you be able to do that? Are you looking for any help maintaining this repo?

couldn't find key message

Hi what if the phone doesn't have Facebook installed ?

I got this error:

screen shot 2016-10-07 at 1 53 36 pm

I tried to catch the error but it wasn't' posible.

Any advice ?

Thanks!

Install completely fails for both iOS & Android

Running React Native 0.34. Followed your automatic installation steps and am getting these errors:

Android:

/Users/dwilt/Projects/GJS/gjs-app/android/app/src/main/java/com/greatjonesstreet/MainApplication.java:37: error: constructor FBSDKPackage in class FBSDKPackage cannot be applied to given types;
            new FBSDKPackage(),

screenshot 2016-09-30 13 54 39

iOS:

'FBSDKShareKit/FBSDKSharekit.h' file not found

screenshot 2016-09-30 13 53 24

I noticed that you are not including any of the Facebook SDK stuff in your manual instructions but it is being populated via the react-native link. Not sure if this is related or your documentation to manually install just needs to be updated.

Share on iOS throws fatal error when user cancels share

When trying to share with the following code on iOS when the user hits the Cancel button a fatal error is thrown by this line.

Share.open({
    message: 'message',
    url: 'http://domain.com/page1',
    title: 'Share Page',
}).done();

It seems to me like this should be a resolve rather than a reject along with whether or not the user shared or not. Throwing an error because the user tapped a valid button seems a little strange to me.

This is probably more a suggestion rather than an issue, because I can easily append a .catch() before the .done().

Error building DependencyGraph

After installation:

Error building DependencyGraph:
Error: Naming collision detected: /home/lukas/Documents/DEVELOP/React-Native/ski-app-mobile/node_modules/react/node_modules/fbjs/lib/getActiveElement.js collides with /home/lukas/Documents/DEVELOP/React-Native/ski-app-mobile/node_modules/react-native/node_modules/fbjs/lib/getActiveElement.js
at HasteMap._updateHasteMap (HasteMap.js:132:13)
at HasteMap.js:103:28
at tryCallOne (/home/lukas/Documents/DEVELOP/React-Native/ski-app-mobile/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
at /home/lukas/Documents/DEVELOP/React-Native/ski-app-mobile/node_modules/react-native/node_modules/promise/lib/core.js:123:15
at flush (/home/lukas/Documents/DEVELOP/React-Native/ski-app-mobile/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
at doNTCallback0 (node.js:408:9)
at process._tickCallback (node.js:337:13)

Uninnstall doesnt work. What happens?

Feature request - Add method to share local files using UIDocumentInteractionController

Thank you for sharing your work! I had a feature request:

Use Case: To share a local app generated file with installed iOS apps such as "Copy to Google Earth"

urlToLocalKmlFile: file:///var/mobile/Containers/Data/Application/13052-F5A9-48FF-90F7-613A3E75F4/Documents/Demo_Parking_Lot.kml

Implementation Example:
https://github.com/deldreth/react-native-document-controller/blob/master/DocumentController.m

Or perhaps keep same interface, and switch to use UIDocumentInteractionController if URL scheme begins with "file://"

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.