How can I share a video as a background and an image as a sticker together to Instagram Story?
This documentation has only one solution if both contents are images.
https://developers.facebook.com/docs/instagram/sharing-to-stories/
I would like to send a background video together with a sticker image. Is that possible with Instagram Story?
I tried that, but unfortunately it didn't work:
// Define image asset URI and attribution link URL
Uri backgroundAssetUri = Uri.fromFile(new File(backgroundPath));
Uri stickerAssetUri = Uri.fromFile(new File(stickerPath));
// Instantiate implicit intent with ADD_TO_STORY action,
// background asset, and attribution link
Intent intent = new Intent("com.instagram.share.ADD_TO_STORY");
intent.setDataAndType(backgroundAssetUri, "*/*");
intent.putExtra("interactive_asset_uri", stickerAssetUri);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
callbackManager.startActivityForResult(Intent.createChooser(intent, "Share"), NatShareCallbacks.ACTIVITY_SHARE_INSTAGRAM_STORY);
But the example with two images works without problems. I see the problem mainly with SetType, because they are two different content types.
[EDIT]
Video alone without stickers had already worked for me on Android and the example of the documentation with image-background and image-sticker also works perfectly. But not video and sticker together.
It works under iOS without any problems:
NSData *backgroundVideo = [[NSFileManager defaultManager] contentsAtPath:path];
UIImage *appIcon = [UIImage imageNamed: [[[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIcons"] objectForKey:@"CFBundlePrimaryIcon"] objectForKey:@"CFBundleIconFiles"] objectAtIndex:0]];
// Verify app can open custom URL scheme, open
NSURL *urlScheme = [NSURL URLWithString:@"instagram-stories://share"];
if ([[UIApplication sharedApplication] canOpenURL:urlScheme]) {
// Assign background image asset and attribution link URL to pasteboard
//NSArray *pasteboardItems = @[@{@"com.instagram.sharedSticker.backgroundVideo" : backgroundVideo}];
NSArray *pasteboardItems = @[@{@"com.instagram.sharedSticker.backgroundVideo" : backgroundVideo, @"com.instagram.sharedSticker.stickerImage" : UIImagePNGRepresentation(appIcon)}];
NSDictionary *pasteboardOptions = @{UIPasteboardOptionExpirationDate : [[NSDate date] dateByAddingTimeInterval:60 * 5]};
// This call is iOS 10+, can use 'setItems' depending on what versions you support
[[UIPasteboard generalPasteboard] setItems:pasteboardItems options:pasteboardOptions]; [[UIApplication sharedApplication] openURL:urlScheme options:@{} completionHandler:nil];
} else {
// Handle older app versions or app not installed case
}
This was a bug.
Facebook wrote: "They've added the functionality now to Android as well, so you should be able to send a background with a sticker now."