【问题标题】:React Native Share Image via Whats App and Facebook通过 Whatsapp 和 Facebook React Native 分享图片
【发布时间】:2019-03-09 17:08:11
【问题描述】:

我正在尝试从 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);
                })

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

【问题讨论】:

标签: react-native share


【解决方案1】:

这是github 中的一个未解决问题,该问题仅在与whats 应用共享时出现在IOS 上。问题是 shareImageBase64 下的消息覆盖了 url 并且您仅共享消息,解决方法是删除消息,您将能够成功共享图像。

【讨论】:

    猜你喜欢
    • 2023-03-21
    • 2014-05-29
    • 2023-03-14
    • 1970-01-01
    • 2013-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多