首页 > 解决方案 > Cordova 应用程序 IOS 中的社交共享

问题描述

我正在尝试通过使用此插件在微信和 WhatsApp 中分享图像:EddyVerbruggen/SocialSharing-PhoneGap-Plugin

window.plugins.socialsharing.shareVia('whatsapp','msg',null, 
      'images/hello.png' , null /* url */, function(e) {
   console.log('share' +e)
 }, function(errormsg){
   alert(errormsg)
 })

window.plugins.socialsharing.shareVia('com.tencent.mm','msg',null, 
      'images/hello.png' , null /* url */, function(e) {
   console.log('share' +e)
 }, function(errormsg){
   alert(errormsg)
 })

我的应用程序在 ios 中崩溃,但在 android 中运行正常。

通过使用另一种方法 shareViaWhatsapp:

window.plugins.socialsharing.shareViaWhatsApp('Message via WhatsApp' 
  ,'images/hello.png', function() {
        console.log('share ok')
        }, function(errormsg){
           alert(errormsg)
        })

此方法在 android 中有效,但在 ios 中显示当我共享图像时要共享的所有应用程序,如果我只共享消息它在 ios 中正常工作。请指导我。

标签: androidioscordovacordova-plugins

解决方案


在我的情况下,我可以确认,使用 shareViaWhatsApp 与 WhatsApp 共享不适用于 iO。我能够共享图片的唯一方法是使用您提到的插件的共享表。所以它是这样的:

this.socialSharing.share(null, null, this.screen, null).then(() => {  
console.log(' succ share test')
  this.shareWhatsApp()
}).catch((e) => {
  console.log(' err share test')
  this.shareWhatsApp()
});


推荐阅读