React-native: How to share image/file to another app(using Share.share)?

Created on 20 Jan 2018  Â·  8Comments  Â·  Source: facebook/react-native

Is this a bug report?

maybe

Have you read the Contributing Guidelines?

yes

Environment

Environment:
OS: macOS High Sierra 10.13.2
Node: 9.3.0
Yarn: 1.3.2
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.52.0 => 0.52.0

Target Platform: iOS (10.3),Android(7.1.1)

Steps to Reproduce

1.create base64 string or local filename
2.use Share.share option
3.
` const content = {
message: ICON_PLUS_BASE64,
//or: message: 'file:///data/0/tmp/..........',
title: 'share',
url: ICON_PLUS_BASE64,
};
const option = { dialogTitle: 'title title title' };
Share.share(content, option);

const ICON_PLUS_BASE64 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB+2/ab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw+P/eMrC5UTVAAAAABJRU5ErkJggg==';
`

Expected Behavior

(Write what you thought would happen.)
App will share(maybe export is more accurate) the image to another app(eg,iMessage,evernote,wechat,etc)

Actual Behavior

The destination app only receive string message but not image.

Reproducible Demo

https://snack.expo.io/@monkingame/test-share

Ran Commands Locked

Most helpful comment

Hey @lucasbento! Sadly, I have no updates. I might try to take a look at the code and try to solve it myself but I have no experience with iOS native code. If I have any kind of success I'll create a PR and let you know!

All 8 comments

I'm experiencing the same behaviour when sharing using whatsapp. When sharing with email the file is attached but with no extension.

@MatiasBontempo: what did you end up using? I keep finding your comments in multiple places with the same errors that I'm experiencing. 😄

Hey @lucasbento! Sadly, I have no updates. I might try to take a look at the code and try to solve it myself but I have no experience with iOS native code. If I have any kind of success I'll create a PR and let you know!

Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version?

I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer.

How to Contribute • What to Expect from Maintainers

For anyone that's having a problem with this, I used file sharing with react-native-fetch-blob and react-native with PR EstebanFuentealba/react-native-share#215.

@lucasbento Did you have a problem installing react-native-share? After installing my app crashes
https://stackoverflow.com/questions/49392736/react-native-build-successful-but-app-crashes

@sturmenta: your link is giving 404, if you still need help I think it's better to create an issue on react-native-share.

@lucasbento Sorry, delete the stackoverflow post because I did not have any kind of way to show the error I doubted they could help me, finally I had problems in the AndroidManifest.xml with the provider. This is the link to how I solved the problem published as an issue in react-native-share: https://github.com/EstebanFuentealba/react-native-share/issues/227.

Thanks also for your help. Regards!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anchetaWern picture anchetaWern  Â·  3Comments

WG-Com picture WG-Com  Â·  3Comments

grabbou picture grabbou  Â·  3Comments

phongyewtong picture phongyewtong  Â·  3Comments

aniss picture aniss  Â·  3Comments