简体   繁体   English

Ionic 5 socialSharing.shareViaWhatsAppToPhone 未附加图像

[英]Ionic 5 socialSharing.shareViaWhatsAppToPhone not attaching image

I am using Social Sharing plugin in Ionic 5 and having issues in sharing image via whatsApp.我在 Ionic 5 中使用社交共享插件,并且在通过 WhatsApp 共享图像时遇到问题。 If I share image via "shareViewWhatsApp" then everything works fine.如果我通过“shareViewWhatsApp”共享图像,那么一切正常。 After selecting contact it shows image that I am sharing.选择联系人后,它会显示我正在共享的图像。

But if I use "shareViaWhatsAppToPhone" or "shareViaWhatsAppToReceiver" to share image whatsapp contact directly then it seems to ignore the image and only shares text message.但是,如果我使用“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()" is just a plug in to convert Dom node to image. “domtoimage.toPng()”只是一个将Dom节点转换为图像的插件。 Ref: https://github.com/tsayen/dom-to-image参考: https://github.com/tsayen/dom-to-image

dataUrl looks like: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..." dataUrl 看起来像:“数据:图像/png;base64,iVBORw0KGgoAAAANSUhEUg...”

Any help would be much appriciated.任何帮助将不胜感激。

Thanks谢谢

Hi i had the same issue earlier later i found out in this documentation( https://www.npmjs.com/package/cordova-plugin-x-socialsharing ) it is clearly mentions files are ignored in android while sending directly to number嗨,我早些时候遇到了同样的问题,后来我在这个文档中发现( https://www.npmjs.com/package/cordova-plugin-x-socialsharing )它清楚地提到文件在 android 中被忽略,同时直接发送到号码在此处输入图像描述

so u can try something like所以你可以尝试类似的东西

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.

相关问题 Ionic socialSharing插件无法在iOS上运行 - Ionic socialSharing plugin not working on iOS 如何通过ionic中的socialsharing插件共享一组图像文件链接或多个图像? - How to share an array of image file links or multiple images through socialsharing plugin in ionic? 离子无法添加SocialSharing-PhoneGap-插件 - ionic unable to add SocialSharing-PhoneGap-Plugin 仅适用于IOS的Whatsapp上的cordova / ionic社会共享错误 - cordova/ionic socialsharing error on Whatsapp only for IOS 在ionic 3中使用socialSharing插件时我的应用程序崩溃 - my app crash when use socialSharing plugin in ionic 3 Ionic Cordova Social Share 插件 - 无法读取未定义的属性“socialsharing” - Ionic Cordova Social Share plugin - cannot read property 'socialsharing' of undefined 使用带有链接的 Cordova SocialSharing 插件将图片分享到 Facebook - Share image to Facebook using Cordova SocialSharing plugin with link attached 更新 cordova-plugin-x-socialsharing 插件后,Ionic Android 构建错误 - Ionic Android build error after updating cordova-plugin-x-socialsharing plugin 无法通过SocialSharing-PhoneGap-Plugin从dataDirectory共享图像 - Can't share image from dataDirectory via SocialSharing-PhoneGap-Plugin 为什么我不能使用 cordova-plugin-x-socialsharing 在 MMS cordova ios 中共享消息和图像 - Why can't I share both message and image in MMS cordova ios using cordova-plugin-x-socialsharing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM