通过Whats App和Facebook反应本机共享图像

时间:2019-03-09 17:08:12

标签: react-native share

我试图从url下载图像,然后通过whats应用程序和其他社交媒体以图像格式共享它,我尝试了一些方法,但是我不能,我的代码如下:

let filePath = null;
        const configOptions = {
            fileCache: true,
        };
        RNFetchBlob.config(configOptions)
            .fetch('GET', url)
            .then(async resp => {
                filePath = resp.path();
                let options = {
                    url: filePath 
                };
                await Share.open(options);
                await RNFS.unlink(filePath);
            });

我也尝试过

RNFetchBlob.fetch("GET",url,{
                    Authorization : 'Bearer access-token...',
                  })
                .then(resp => {
                    console.log(resp)
                  let shareImageBase64 = {
                    title: "React Native",
                    message: "Hola mundo",
                    url: `data:image/png;base64,` + resp.base64(),

                  };
                  Share.open(shareImageBase64);
                })

它确实打开了共享选项,但是没有图像,只能共享消息。

0 个答案:

没有答案