Sharing to Feed

With Sharing to Feed, you can allow your app's Users to share your content to their Instagram Feed.

Overview

By using Android Implicit Intents and iOS Custom URL Schemes or Document Interaction, your app can pass photos and videos to the Instagram app. The Instagram app will receive this content and load it in the feed composer so the User can publish it to their Instagram Feed.

Android Developers

Android implementations use implicit intents with the EXTRA_STREAM extra to prompt the User to select the Instagram app. Once selected, the intent will launch the Instagram app and pass it your content, which the Instagram App will then load in the Feed Composer.

In general, your sharing flow should:

  1. Instantiate an implicit intent with the content you want to pass to the Instagram app.
  2. Start an activity and check that it can resolve the implicit intent.
  3. Resolve the activity if it is able to.

Shareable Content

You can pass the following content to the Instagram app:

ContentFile TypesDescription

Image asset

JPEG, GIF, or PNG

-

File asset

MKV, MP4

Minimum duration: 3 seconds Maximum duration: 10 minutes Minimum dimentions: 640x640 pixels

Sharing an Image Asset

String type = "image/*";
String filename = "/myPhoto.jpg";
String mediaPath = Environment.getExternalStorageDirectory() + filename;

createInstagramIntent(type, mediaPath);

private void createInstagramIntent(String type, String mediaPath){

    // Create the new Intent using the 'Send' action.
    Intent share = new Intent(Intent.ACTION_SEND);

    // Set the MIME type
    share.setType(type);

    // Create the URI from the media
    File media = new File(mediaPath);
    Uri uri = Uri.fromFile(media);

    // Add the URI to the Intent.
    share.putExtra(Intent.EXTRA_STREAM, uri);

    // Broadcast the Intent.
    startActivity(Intent.createChooser(share, "Share to"));
}

Sharing a Video Asset

String type = "video/*";
String filename = "/myVideo.mp4";
String mediaPath = Environment.getExternalStorageDirectory() + filename;

createInstagramIntent(type, mediaPath);

private void createInstagramIntent(String type, String mediaPath){

    // Create the new Intent using the 'Send' action.
    Intent share = new Intent(Intent.ACTION_SEND);

    // Set the MIME type
    share.setType(type);

    // Create the URI from the media
    File media = new File(mediaPath);
    Uri uri = Uri.fromFile(media);

    // Add the URI to the Intent.
    share.putExtra(Intent.EXTRA_STREAM, uri);

    // Broadcast the Intent.
    startActivity(Intent.createChooser(share, "Share to"));
}

iOS Developers

iOS implementationsc can use our Custom URL Scheme or iOS's Document Interaction API to launch the Instagram app and pass it content, or have it perform a specific action.

Custom URL Scheme

In order for your app to use Instagram's custom URL scheme, you mush whitelist the scheme by adding instagram:// to the LSApplicationQueriesSchemes key in your app's Info.plist.

Once you've whitelisted the scheme, you can use it with the following parameters to have the Instagram app perform specific actions.

Scheme Parameters

URLOpens

app

Launches the Instagram app.

camera

Launches the Instagram app with the camera view or photo library on non-camera devices.

media?id=

Launches the Instagram app and loads the post matching the supplied id value (int).

user?username=

Launches the Instagram app and loads the Instagram user matching the supplied username value (string).

location?id=

Launches the Instagram app and loads the location feed matching the supplied id value (int).

tag?name=

Launches the Instagram app and loads the page for the hashtag matching the supplied name value (string).

For example, to launch the Instagram app with the camera view, you would use instagram://camera.

Sample Objective-C Code

NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
    [[UIApplication sharedApplication] openURL:instagramURL];
}

Document Interaction

If your application creates photos and you'd like your users to share these photos using Instagram, you can use the Document Interaction API to open your photo in Instagram's sharing flow.

You must first save your file in PNG or JPEG (preferred) format and use the filename extension .ig. Using the iOS Document Interaction APIs you can trigger the photo to be opened by Instagram. The Identifier for our Document Interaction UTI is com.instagram.photo, and it conforms to the public/jpeg and public/png UTIs. See the Apple documentation articles: Previewing and Opening Files and the UIDocumentInteractionController Class Reference for more information.

Alternatively, if you want to show only Instagram in the application list (instead of Instagram plus any other public/jpeg-conforming apps) you can specify the extension class igo, which is of type com.instagram.exclusivegram.

When triggered, Instagram will immediately present the user with our filter screen. The image is preloaded and sized appropriately for Instagram. For best results, Instagram prefers opening a JPEG that is 640px by 640px square. If the image is larger, it will be resized dynamically.