[英]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.