2

我正在尝试将 SocialSharing 插件与 PhoneGap Build 一起使用。

我已将以下内容放入 config.ml 文件中:

<gap:plugin name="nl.x-services.plugins.socialsharing" version="4.0.8" />

这是我的 HTML 索引页面的示例:

<html>
    <head>
        <script type="text/javascript" src="SocialSharing.js"></script>
    </head>
    <body>
        <section id="landmarks" data-role="page">
            <button onclick="window.plugins.socialsharing.share('My message')">share!</button>
            <button onclick="window.plugins.socialsharing.share('Message only')">message only</button>
            <button onclick="window.plugins.socialsharing.shareViaTwitter('Message via Twitter')">message via Twitter</button>
        </section>
    </body>
</html>

当我点击按钮时(从 PhoneGapBuild 下载应用程序后)没有任何反应。

有任何想法吗?

4

2 回答 2

3

我决定切换到 PhoneGap/Cordova 命令行界面来构建这个应用程序。当我这样做时,SocialSharing 插件开始完美运行。

我认为问题在于,当我将源文件上传到 PhoneGap Build 时,我没有正确地将cordova.js文件导入 index.html 页面。SocialSharing.js

cordova.js大家注意:让脚本成为您在 HTML 页面中导入的第一个脚本很重要,因为您可能会无意中使用依赖于 Cordova 平台的功能,并且如果cordova.js稍后导入文件,该功能将不起作用.

于 2014-06-06T16:40:23.737 回答
1

对于使用cordova 3.6.3左右的thouse,我遇到了同样的问题,发现通过window.plugins调用插件现在已被弃用并且已经不适合我了。

我向插件所有者提交了一个问题,并为我自己更改了插件。只需要更改插件js的页脚

--deleted window.plugins.socialsharing....
module.exports= new SocialSharing();

不调用任何 window.plugin 等...并从您的 js socialsharing=cordova.require("nl.x-services.plugins.socialsharing.SocialSharing"); 那么你可以使用 socialsharing.share(...) 希望这对某人有帮助!

于 2014-10-08T08:45:34.470 回答