Reputation: 11
I am using https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin for Social Sharing on Ionic Framework.
The below code shares the image with a text and a link ,it works very fine for Android on whatsapp but when it comes to iOS only text is shared instead of image on whatsapp. This is the code below :
$scope.myCardShare=function (){
var message="My Message";
var subject="My Subject";
var file="www/"+$scope.finalImage; //My image location
var link="https://google.com"; //Link
console.log(file);
$cordovaSocialSharing
.share(message, subject, file, link) // Share via native share sheet
.then(function(result) {
// Success!
}, function(err) {
// An error occured. Show a message to the user
});
}
Please help
Upvotes: 1
Views: 2801
Reputation: 177
You can try this:
$scope.myCardShare=function (){
var message="My Message";
var subject="My Subject";
var file="www/"+$scope.finalImage; //My image location
var link="https://google.com"; //Link
console.log(file);
$cordovaSocialSharing
.share(null, subject, file, message + '\n' + link) // Share via native share sheet
.then(function(result) {
// Success!
}, function(err) {
// An error occured. Show a message to the user
});
}
The whatsapp share will check if message is null, if it is null will send image with url, and this url will contains the message and the url.
Upvotes: 0
Reputation: 41
Hey I am running into the same problem too. I realize that if both "message" and "files" field are present, whatsapp will only share the text but not the file. When I remove the "message" field, the image got sent.
Why don't you try checking the platform by ionic.Platform.isIOS() and remove the "message" field if it's ios?
var message="My Message";
var subject="My Subject";
var file="www/"+$scope.finalImage; //My image location
var link="https://google.com"; //Link
console.log(file);
if(ionic.Platform.isIOS()) {
$cordovaSocialSharing
.share(null, null, file, link) // Share via native share sheet
.then(function(result) {
// Success!
}, function(err) {
// An error occured. Show a message to the user
});
} else {
$cordovaSocialSharing
.share(message, subject, file, link) // Share via native share sheet
.then(function(result) {
// Success!
}, function(err) {
// An error occured. Show a message to the user
});
}
Upvotes: 4