With Sharing to Feed, you can allow your app's Users to share your content to their Instagram Feed.
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 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:
You can pass the following content to the Instagram app:
Content | File Types | Description |
---|---|---|
Image asset | JPEG, GIF, or PNG | - |
File asset | MKV, MP4 | Minimum duration: 3 seconds Maximum duration: 10 minutes Minimum dimentions: 640x640 pixels |
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")); }
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 implementations 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.
In order for your app to use Instagram's custom URL scheme, you must add the scheme to the allow list by adding instagram://
to the LSApplicationQueriesSchemes
key in your app's Info.plist
.
Once you've added the scheme to the allow list, you can use it with the following parameters to have the Instagram app perform specific actions.
Scheme Parameters
URL | Opens |
---|---|
| Launches the Instagram app. |
| Launches the Instagram app with the camera view or photo library on non-camera devices. |
| Launches the Instagram app and loads the post matching the supplied id value ( |
| Launches the Instagram app and loads the Instagram user matching the supplied username value ( |
| Launches the Instagram app and loads the location feed matching the supplied id value ( |
| Launches the Instagram app and loads the page for the hashtag matching the supplied name value ( |
For example, to launch the Instagram app with the camera view, you would use instagram://camera
.
NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"]; if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) { [[UIApplication sharedApplication] openURL:instagramURL]; }
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.