繁体   English   中英

Ionic 5 socialSharing.shareViaWhatsAppToPhone 未附加图像

[英]Ionic 5 socialSharing.shareViaWhatsAppToPhone not attaching image

我在 Ionic 5 中使用社交共享插件,并且在通过 WhatsApp 共享图像时遇到问题。 如果我通过“shareViewWhatsApp”共享图像,那么一切正常。 选择联系人后,它会显示我正在共享的图像。

但是,如果我使用“shareViaWhatsAppToPhone”或“shareViaWhatsAppToReceiver”直接分享图片whatsapp联系人,那么它似乎会忽略图片而只分享短信。

var node = document.getElementById('body') ;
domtoimage.toPng(node) 
    .then((dataUrl) => {
      this.socialSharing.shareViaWhatsAppToPhone('+61xxxxxxxxx','share toPhone', dataUrl,null).then((res) => {
        console.log('image shared with whatsapp');
      }).catch((e) => {
        console.error('social share, something went wrong!', e);
      });
    })
    .catch((error) => {
        console.error('oops, something went wrong!', error);
    });

“domtoimage.toPng()”只是一个将Dom节点转换为图像的插件。 参考: https://github.com/tsayen/dom-to-image

dataUrl 看起来像:“数据:图像/png;base64,iVBORw0KGgoAAAANSUhEUg...”

任何帮助将不胜感激。

谢谢

嗨,我早些时候遇到了同样的问题,后来我在这个文档中发现( https://www.npmjs.com/package/cordova-plugin-x-socialsharing )它清楚地提到文件在 android 中被忽略,同时直接发送到号码在此处输入图像描述

所以你可以尝试类似的东西

this.socialSharing.shareViaWhatsApp('share toPhone', dataUrl,null).then((res) => {
      console.log('image shared with whatsapp');
    }).catch((e) => {
      console.error('social share, something went wrong!', e);
    });
  })
  .catch((error) => {
      console.error('oops, something went wrong!', error);
  });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM