【问题标题】:PhoneGap Build: SocialSharing Plugin Not LoadingPhoneGap Build:SocialSharing 插件未加载
【发布时间】:2014-07-27 06:12:33
【问题描述】:

我正在尝试将 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 下载应用程序后),没有任何反应。

有什么想法吗?

【问题讨论】:

    标签: jquery cordova phonegap-plugins phonegap-build socialshare


    【解决方案1】:

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

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

    所有人注意:将cordova.js 脚本作为您在 HTML 页面中导入的第一个脚本很重要,因为您可能会无意中使用依赖于 Cordova 平台的函数,并且如果 cordova.js 文件稍后导入,该功能将无法使用。

    【讨论】:

      【解决方案2】:

      对于使用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"); 那么你可以使用 社交分享.share(...) 希望这对某人有帮助!

      【讨论】:

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