npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-instagram-salesfloor

v0.5.8

Published

Share the content of a canvas element or a dataUrl encoded image using the Instagram application for iOS and Android.

Downloads

7

Readme

Instagram plugin for Cordova

By Vlad Stirbu.

Adds ability to share the content of a canvas element or a dataUrl encoded image using the Instagram application for iOS and Android.

GitHub version Stories in Ready Join the chat at https://gitter.im/vstirbu/InstagramPlugin

Installing the plugin to your project

If you use cordova-cli newer than 5.0:

cordova plugin add cordova-instagram-plugin

or, for older versions:

cordova plugin add https://github.com/vstirbu/InstagramPlugin

Instagram plugin JavaScript API

Detect if the Instagram application is installed on the device. The function isInstalled accepts a callback function as parameter:

Instagram.isInstalled(function (err, installed) {
    if (installed) {
        console.log("Instagram is", installed); // installed app version on Android
    } else {
        console.log("Instagram is not installed");
    }
});

Share the content of a canvas element or a base64 dataURL png image. The function share accepts a string, corresponding to the canvas element id or the dataURL, an optional caption, and a callback function as parameters:

API CHANGE NOTE: Instagram app stopped accepting pre-filled captions on both iOS and Android. As a work-around, the caption is copied to the clipboard. You have to inform your users to paste the caption.

Instagram.share(canvasIdOrDataUrl, caption, function (err) {
    if (err) {
        console.log("not shared");
    } else {
        console.log("shared");
    }
});

or:

Instagram.share(canvasIdOrDataUrl, function (err) {
    if (err) {
        console.log("not shared");
    } else {
        console.log("shared");
    }
});

Share library asset image or video. The function shareAsset (iOS only) accepts a string with asset local identifier, and a callback function as parameters:

var assetLocalIdentifier = "24320B60-1F52-46AC-BE4C-1202F02B9D00/L0/001";
Instagram.shareAsset(function(result) {
            console.log('Instagram.shareAsset success: ' + result);
        }, function(e) {
            console.log('Instagram.shareAsset error: ' + e);
        }, assetLocalIdentifier);

You can get a LocalIdentifier by using Photos Framework Fetching Assets API

A very basic application that uses the plugin can be found here.

AngularJS/Ionic

The plugin is included in ngCordova and ionic-native.

NOTE: If you are using an image from the server,then you should download the image and fetch the content using readAsDataURL. Example:

var url = encodeURI('https://static.pexels.com/photos/33109/fall-autumn-red-season.jpg');
var filename = 'image.jpg';
var targetPath = cordova.file.externalRootDirectory + filename;
$cordovaFileTransfer.download(url, targetPath, {}, true).then(function(result) {
        var mywallpaper = result.toURL();
        window.resolveLocalFileSystemURL(mywallpaper, function(fileEntry) {
            fileEntry.file(function(file) {
                var reader = new FileReader(),
                    data = null;
                reader.onloadend = function(event) {
                    data = reader.result;
                    $cordovaInstagram.share(data, '#amazing').then(function(success) {
                        console.log('shareViaInstagram Success', success);
                    }, function(err) {
                        console.log('shareViaInstagram failed', err);
                    });
                };
                reader.readAsDataURL(file)
            });
        });
    },
    function(error) {},
    function(progress) {
});

Quirks:

Android

  • Passing caption in addition to sharing image requires Instagram Android application version 6.1.0 or higher.
  • Older versions of Android (2.x-3.x) do not have proper support for toDataURL on canvas elements. You can still get the canvas content as dataURL following these instructions. Pass the dataUrl instead of the canvas id to share.

iOS

  • Although the plugin follows the instructions to show only Instagram in the document interaction controller, there are reports that other apps appear in the list.

Recipes

  • Sharing image when knowing the file url.

License

The plugin is available under MIT license.