4

I am using react-native-share to share something in hangouts, whatsapp and so on... here is my code that i tried,

i imported the

import RNFetchBlob from 'react-native-fetch-blob';
import Share from 'react-native-share';

so used RNFetchblob to convert image url to base64, and added the dependencies based on the api.

_downloadImageAndShare(title, message, url) {
const { fs } = RNFetchBlob.fs;
var self = this;
RNFetchBlob.config({ fileCache: true })
  .fetch('GET', url)
  .then(resp => {       
    return resp.readFile('base64')
      .then(base64 => {
        return { resp, base64 };
      })
  })
  .then(obj => {
    console.log(obj)
    var headers = obj.resp.respInfo.headers;
    var type = headers['Content-Type'];
    var dataUrl = 'data:' + type + ';base64,' + obj.base64;
    console.log('dataurl is', dataUrl)
    return { title, message, url: dataUrl };

  })
  .then(options => {
    return Share.open(options); 
    console.log('options is', options)
  }).catch(err => {err && console.log(err); })         
 }

<ShareIcon onTrigger={ () => this._downloadImageAndShare('sample', `${title} sample. More http://www.sample.com`, shareImage) } white={!!whiteIcon} />

here I am getting the response image url converted in base64 format. I want to share the a content , link and the image. These procedure working fine in iOS.

But in android image is not getting share.

khalifathul
  • 558
  • 1
  • 10
  • 24
  • Since you got a solution in https://github.com/react-native-community/react-native-share/issues/233, maybe you can add the solution to this Stack Overflow entry? – Motin Apr 26 '19 at 08:46

0 Answers0