PhoneGap Build: SocialSharing Plugin Not Loading

↘锁芯ラ 提交于 2019-12-13 01:29:37

问题


I am trying to use the SocialSharing Plugin with PhoneGap Build.

I have put the following into the config.ml file:

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

Here is a sample of my HTML index page:

<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>

When I tap the buttons (after downloading the app from PhoneGapBuild) nothing happens.

Any ideas?


回答1:


I decided to switch to the PhoneGap/Cordova Command Line Interface to build this app. When I did, the SocialSharing plugin began to work perfectly.

I believe the problem was that I had not correctly imported the cordova.js and SocialSharing.js files into the index.html page when I uploaded my source to PhoneGap Build.

Note to Everyone: it is important to have the cordova.js script be the first script you import in your HTML page, as you may inadvertently use a function that relies on the Cordova platform, and, if the cordova.js file is imported later, the feature will not work.




回答2:


For thouse using cordova 3.6.3 or so I had the same problem and found that calling plugins by window.plugins is now deprecated and already not working for me.

I submited an issue to the plugin owner and changed for my self the plugin. just need to change the footer of the plugin js with

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

Not calling any window.plugin etc... and from your js socialsharing=cordova.require("nl.x-services.plugins.socialsharing.SocialSharing"); then you can use socialsharing.share(...) Hope this helps someone!



来源:https://stackoverflow.com/questions/24073950/phonegap-build-socialsharing-plugin-not-loading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!