[英]how to share images on whatsapp through ionic app
在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>
下面是我的控制器
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);
}
});
我可以分享文字,但不會添加圖片
我可能完全做錯了,請事先告知我正確的方法是什么
單擊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!
});
}
只需將消息,圖像和URL聲明為字符串即可。
參數image應該是Image的路徑(URL)。 而不是圖像數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.