【问题标题】:phonegap how to use social share plugin?phonegap 如何使用社交分享插件?
【发布时间】:2015-04-16 09:43:23
【问题描述】:

我正在使用这个插件 SocialSharing-PhoneGap-Plugin

我用过这个代码

<!-- unlike most apps Twitter doesn't like it when you use an array to pass multiple files as the second param -->
<button onclick="window.plugins.socialsharing.shareViaTwitter('Message via Twitter')">message via Twitter</button>
<button onclick="window.plugins.socialsharing.shareViaTwitter('Message and link via Twitter', null /* img */, 'http://www.x-services.nl')">msg and link via Twitter</button>

我的手机中有 twitter 应用程序 它运行良好。我的手机中没有 twitter 应用程序,它无法正常工作。你能帮助我吗?假设如果我在移动设备中没有 twitter 应用程序。自动转到 Web 浏览器 分享我的内容

【问题讨论】:

  • 插件文档是否说明需要在手机上安装应用程序?
  • 我认为没有 @Cristik 。该文档仅 twitter、facebook 共享内容仅 ios 和 android 手机

标签: jquery cordova twitter phonegap-plugins socialshare


【解决方案1】:

我们遇到了同样的问题,并找到了解决方案。

其实shareByTwitter函数可以使用5个参数, 最后一个是 onError 函数,在未安装 Twitter App 时启动。 所以我们在这个函数中添加了对 Twitter 分享页面的调用,现在它可以正常工作了:

window.plugins.socialsharing.shareViaTwitter(
    /* message */ 'Message via Twitter', 
    /* img */ null, 
    /* url */ yourPermalink , 
    /* function onSuccess */ function() {
        console.log('share ok');
    }, 
    /* function onError */ function(errormsg){
        // when Twitter app is not installed : directly open twitter on web browser
        window.open('https://twitter.com/share?url=' + yourPermaLink, '_blank');
    }
)

(见https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin#sharing-directly-to

您还可以选择使用 market:// 或类似的方式将用户重定向到 PlayStore 或 AppStore 上的 Twitter 应用程序。

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多