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 Universal Links 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 implementations can use universal links to launch the Instagram app and pass it content, or have it perform a specific action.

Universal Links

Use the universal links listed in the following table to perform actions in the Instagram app.

Universal linkAction

https://www.instagram.com

Launch the Instagram app.

https://www.instagram.com/create/story

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

https://www.instagram.com/p/{media_id}

Launch the Instagram app and load the post that matches the specified ID value (int).

https://www.instagram.com/{username}

Launch the Instagram app and load the Instagram user that matches the specified username value (string).

https://www.instagram.com/explore/locations/{location_id}

Launch the Instagram app and load the location feed that matches the specified ID value (int).

https://www.instagram.com/explore/tags/{tag_name}

Launch the Instagram app and load the page for the hashtag that matches the specified name value (string).

Sample Objective-C Code

The following example in Objective-C launches the Instagram app with the camera view.

NSURL *instagramURL = [NSURL URLWithString:@"https://www.instagram.com/create/story"];
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.