简体   繁体   English

如何通过离子应用程序在whatsapp上共享图像

[英]how to share images on whatsapp through ionic app

Need little help on cordovaSocialShare plugin I'm trying to share an image via Whatsapp which was selected in my ionic app but i'm not able to share the image 在cordovaSocialShare插件上需要很少的帮助我正在尝试通过在我的离子应用程序中选择的Whatsapp共享图像,但是我无法共享图像

<form name = myForm controller="ExampleController" ng-
submit="ShareAnywhere(myForm)">
<div class="myDivClass">
<input type="file" ng-model="share.shareImage">
<button ng-click="Submitted=true">Share</button>
</div>
<form>

and below goes my controller 下面是我的控制器

app.controller('ExampleController',function($scope, $cordovaSocialSharing, $filter){
$scope.shareAnywhere=function(myForm){


    var eDate = new Date();
    var message = "Hi! this is an wahtsapp msg";
    var image = this.share.shareImage;
    var link = 'http://myAwsomeWebsite.com';
    var subject = 'My Subject';
    $cordovaSocialSharing.share(message, subject, image, link);
}
});

I'm able to share the text but it wouldn't add image with it 我可以分享文字,但不会添加图片

I might be doing it completely wrong please let me know what is the correct way to do it thanks in advance 我可能完全做错了,请事先告知我正确的方法是什么

For capturing the image on click of button added at HTML file: 单击HTML文件上添加的按钮以捕获图像:

takePicture(){
    Camera.getPicture({
        destinationType: Camera.DestinationType.DATA_URL,
        targetWidth: 1000,
        targetHeight: 1000
    }).then((imageData) => {
      // imageData is a base64 encoded string
        this.base64Image = "data:image/jpeg;base64," + imageData;

    }, (err) => {
        console.log(err);
    });
  }
sharePicture(){

// Share via whatsapp

this.socialSharing.shareViaWhatsApp(this.message,this.base64Image,this.url).then(() => {
  // Success!
}).catch(() => {
  // Error!
});
}

Just declare the message, image and url as string. 只需将消息,图像和URL声明为字符串即可。

the parameter image should be a path(URL) to the Image. 参数image应该是Image的路径(URL)。 and not the Image data. 而不是图像数据。

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

相关问题 如何将我的应用程序中的图像分享到whatsapp? - how to share images from my app to whatsapp? 如何将多个图像共享到whatsapp应用程序? - how to share multiple images to whatsapp app? 如何在android中通过whatsapp共享pdf和文本? - How to share pdf and text through whatsapp in android? 如何通过Instagram,Whatsapp或任何社交应用程序从自己的应用程序共享图像文件? - How to share the image file from your own app through Instagram, Whatsapp or maybe any social app? 如何使用移动应用程序进入whatsapp共享链接? - How to use mobile app into whatsapp share link? 如何从我的应用程序将文本分享到 WhatsApp? - How to share text to WhatsApp from my app? 使用设备库中的共享功能将图像发送到Ionic应用程序,类似于分享给whatsapp - Use Share feature from device gallery to send an image to Ionic app ,similar to share to whatsapp 通过WhatsApp共享图像和文本 - Share image and text through whatsapp 如何以编程方式通过 whatsapp android 共享图像和文本 - How to Share both image and text through whatsapp android programatically 如何在自定义Android应用程序中实现“在whatsapp上共享”功能? - How to implement a “share on whatsapp” feature in a custom Android app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM