Search code examples
jquerycordovaphonegap-pluginsphonegap-buildsocialshare

PhoneGap Build: SocialSharing Plugin Not Loading


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?


Solution

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