Add Social Sharing Feature to HTML5 Game using Intel XDK

If you have gone through previous post in which we discussed about using Intel XDK to compile HTML5 games to Android apps, next steps are to add features which are quite necessary for every Android app such Social Sharing option. There are many open source plugins available to add Social Sharing feature to your app and it takes no more than a few minutes of effort to integrate this feature and get it working. The steps are as following

  • Open your app in Intel XDK and go to CORDOVA HYBRID MOBILE APP SETTINGS section

  • Click on “Add Plugins to this project” and search for the plugin “cordova-plugin-x-socialsharing” in npm. Click “Add Plugin” which adds plugin to the project.

  • Open your index.html and add following code
        <script>
            function share(){
                window.plugins.socialsharing.share('Sample', null, null, 'https://play.google.com/store/apps/details?id=com.html5games.sample');
            }
        </script>
    

    Replace title and URL of the Android app in the code. And that is it. Now the share method is available to call on click of a button, or icon, or on any other action which opens the standard Android Social Sharing pop-up.

For further details on this plugin refer to github.

 


Leave A Comment

Your email address will not be published.