2016-05-30 36 views
0

我在Ionic Framework上使用https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin進行社交共享。iOS上的Ionic Framework中的WhatsApp上的圖像共享

下面的代碼將圖像與文本和鏈接共享,它在Android上對whatsapp非常優秀,但對於iOS而言,只有文本在whatsapp上共享而不是圖像。這是下面的代碼:

$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 
}); 
} 

請幫

+0

你能否提出更具體的問題?這看起來有點像'你能完成我的功課嗎?'對我來說。 – iwein

+0

完成,你可以檢查並建議 – user6401487

回答

2

嘿我遇到了同樣的問題了。我意識到,如果「message」和「files」字段都存在,whatsapp將只共享文本而不是文件。當我刪除「消息」字段時,圖像被髮送。

爲什麼不嘗試通過ionic.Platform.isIOS()檢查平臺並刪除「消息」字段,如果它是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 
     }); 
    } 
0

你可以試試這個:

$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 
}); 
} 

的WhatsApp的份額將檢查信息爲空,如果是空將發送圖像的URL,而這個URL將包含在郵件和URL。

相關問題