【问题标题】:Image sharing on Whatsapp in Ionic Framework on iOSiOS 上 Ionic 框架中 Whatsapp 上的图像共享
【发布时间】:2016-09-28 14:50:06
【问题描述】:

我正在使用 https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin 在 Ionic Framework 上进行社交分享。

以下代码通过文本和链接共享图像,它在 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
});
}

请帮忙

【问题讨论】:

  • 你能把这个问题说得更具体一点吗?这看起来有点像“你能完成我的作业吗?”对我来说。
  • 完成了,你能检查一下并提出建议

标签: ios cordova ionic-framework whatsapp


【解决方案1】:

嘿,我也遇到了同样的问题。我意识到如果“消息”和“文件”字段都存在,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
      });
  }

【讨论】:

    【解决方案2】:

    你可以试试这个:

    $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分享会检查message是否为null,如果为null则会发送带有url的图片,这个url会包含message和url。

    【讨论】:

      猜你喜欢
      • 2018-01-05
      • 2013-12-23
      • 2019-01-28
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 2017-01-01
      • 1970-01-01
      • 2012-12-21
      相关资源
      最近更新 更多