React Native - shared local image with showShareActionSheetWithOptions

I have a question about sharing a local image with showShareActionSheetWithOptions .

Here is my code:

 ActionSheetIOS.showShareActionSheetWithOptions({ title: "React Native", message: "Hola mundo", url: '@theme/img/share/share.png', subject: "Share Link" // for email }); 

From the documentation : "If the URL points to a local file, or it is a base64 encoded URI, then the specified file will be downloaded and transferred directly."

But that will not work. I am not sure how to access or how to get the path to the image. In my application root folder (where index.io.js is located) I have a "src / theme / img" folder where all my images are.

In the example from native-native, they have the image in which the .js file is located, but this also does not work.

+6
source share
1 answer

In the current version of React Native (0.49), valid URLs can be:

  • selected from ImagePicker Expo API
  • screenshot using ReactNative.takeSnapshot('window')

The path is as follows:

 /private/var/mobile/Containers/Data/Application/7A8EA990-D8C0-43B9-A527-365111FCBBA0/tmp/ReactABI21_0_0Native/9BD50E06-3D6F-4E44-9465-A17D6BE399D4.png 

or

 file:///var/mobile/Containers/Data/Application/7A8EA990-D8C0-43B9-A527-365111FCBBA0/Library/Caches/ExponentExperienceData/%2540anonymous%252Ftestapp2-d4b9a2f3-ffbf-4cba-8b8d-cd555cd62ca8/ImagePicker/2D289B12-4090-4F66-AE2B-BCDDB1C3086C.jpg 

However, local image URLs such as ./theme/img/share/share.png are not supported. By the way, asset-library:// URLs are also not supported.

0
source

All Articles