This document shows you how to integrate sharing into your iOS app so that users can share video content to Reels on Instagram.
Reels LayersThe Reels composer has a background video layer and an optional sticker layer.
Sharing Icon
|
Before you can implement sharing in your app, add your app ID and register Instagram's custom URL scheme in the Info.plist file for your app. Add instagram-reels to the LSApplicationQueriesSchemes key.
You use a custom URL scheme to launch the Instagram app and send it content for Reels. The Instagram app receives the content, loads it in the Reels composer, and the user can edit and publish the content to their Instagram Reels.
In general, your sharing flow does the following:
Remove any temporary files that you create on the user's device.
You send the following data when you share to Reels.
| Data | Type | Description | Required |
|---|---|---|---|
Meta App ID | NSString * | Your Meta App ID | Yes |
Background Video | NSURL * | The URL for a video. Videos can be 1080p and should be between 3 and 60 seconds in duration. Acceptable video formats are H.264, H.265, and WebM. Under 50 MB is recommended. | Yes |
Sticker Asset | NSURL * | The URL for an image that is a local file on the user's device. Acceptable image formats are JPG and PNG, and the recommended dimensions are 640 x 480. The image appears over the video. | No |
The following Swift and Objective C code examples show how to send a single image or video, how to send multiple images or videos, and how to send images or videos with a sticker.
The following code example sends a file to Instagram so the user can edit and publish it to their Instagram Reels.
func shareBackgroundVideo() {
// Identify your App ID
let appIDString = "1234567890"
// Identify your video content
guard let backgroundVideoURL = URL(string: "your-video-url-goes-here") else { return }
guard let backgroundVideoData = try? Data.init(contentsOf: backgroundVideoURL) as Data else { return }
// Call method to share video
backgroundVideo(backgroundVideoData: backgroundVideoData, appID: appIDString)
}
// Method to share video
func backgroundVideo(backgroundVideoData: Data, appID: String) {
if let urlScheme = URL(string: "instagram-reels://share"), UIApplication.shared.canOpenURL(urlScheme) {
// Add background video and appID to pasteboard items
let pasteboardItems: [[String: Any]] = [
["com.instagram.sharedSticker.backgroundVideo": backgroundVideoData],
["com.instagram.sharedSticker.appID": appID]
]
// Set pasteboard options
let pasteboardOptions = [UIPasteboard.OptionsKey.expirationDate: Date().addingTimeInterval(60 * 5)]
// Attach the pasteboard items
UIPasteboard.general.setItems(pasteboardItems, options: pasteboardOptions)
UIApplication.shared.open(urlScheme)
} else {
// Handle error cases
}
}The following code example sends a video to Instagram, and includes an optional sticker, so the user can edit and publish it to their Instagram Reels.
func shareBackgroundVideoWithSticker() {
// Identify your App ID
let appIDString = "1234567890"
// Identify your video content
guard let backgroundVideoURL = URL(string: "your-video-url-goes-here") else { return }
guard let backgroundVideoData = try? Data.init(contentsOf: backgroundVideoURL) as Data else { return }
// Identify your sticker content
guard let stickerImage = URL(string: "your-sticker-url-goes-here") else { return }
guard let stickerImageData = try? Data.init(contentsOf: stickerImage) as Data else { return }
// Call method to share video
backgroundVideoWithSticker(backgroundVideoData: backgroundVideoData, stickerImageData: stickerImageData, appID: appIDString)
}
// Method to share video with sticker
func backgroundVideoWithSticker(backgroundVideoData: Data, stickerImageData: Data, appID: String) {
if let urlScheme = URL(string: "instagram-reels://share"), UIApplication.shared.canOpenURL(urlScheme) {
// Add background video, sticker, and appID to pasteboard items
let pasteboardItems: [[String: Any]] = [
["com.instagram.sharedSticker.backgroundVideo": backgroundVideoData],
["com.instagram.sharedSticker.stickerImage": stickerImageData],
["com.instagram.sharedSticker.appID": appID]
]
// Set pasteboard options
let pasteboardOptions = [UIPasteboard.OptionsKey.expirationDate: Date().addingTimeInterval(60 * 5)]
// Attach the pasteboard items
UIPasteboard.general.setItems(pasteboardItems, options: pasteboardOptions)
UIApplication.shared.open(urlScheme)
} else {
// Handle error cases
}
}To make it more convenient for developers, Meta has published sample code for Instagram Share to Reels on GitHub at fbsamples/share_to_reels_ios. Watch the following video to learn how to use the GitHub Sample.