0

我正在使用这个插件 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 应用程序。自动转到Web 浏览器分享我的内容

4

1 回答 1

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 应用程序。

希望它可以帮助

于 2015-06-15T08:59:17.183 回答