Book Image

PhoneGap By Example

Book Image

PhoneGap By Example

Overview of this book

Table of Contents (17 chapters)
PhoneGap By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Sharing on Instagram


Another useful plugin for sharing is the Instagram plugin for Cordova.

Tip

You can read more about this plugin at https://github.com/vstirbu/InstagramPlugin.

It supports both iOS and Android platforms.

The requirement for the plugin is installed in the Instagram application. It will show a notification if Instagram is not installed.

Let's install the plugin as we usually do it:

$ cordova plugins add https://github.com/vstirbu/InstagramPlugin

We already know how to add an event handler on the Instagram share button. Take a Base64 data URL image of the canvas and send it along with the caption:

document.getElementById('share-instagram').addEventListener("click", function() {
    var img = game.canvas.toDataURL();
    var caption = 'I just got ' + score + ' points in Crazy Bubbles!';
    Instagram.share(img, caption, function (err) {
        if (err) {
            console.log("not shared");
        } else {
            console.log("shared");
        }
    });
    return false...