You can share text and media directly to Instagram as an Instagram Reel or directly to the user's Feed.
Checking for availability
Before you share something to Instagram it's best to see first if the app is installed on the user's device. You can do that using the following JS Bridge method
↔️Median JavaScript Bridge
Run the following Median JavaScript Bridge command to share the screen content
const { isInstalled } = await median.socialShare.instagram.isInstalled();
Sharing media
The plugin only supports media sharing as a Blob
object. You can save a remote image as a Blob
using the following code snippet. Some other plugins from Median also export images as Blobs which can then be used with this plugin
fetch("url-to-image")
.then(function(response) {
return response.blob();
})
.then(function(blob) {
// here the image is a blob
});
Sharing to feed
Share the image to Instagram feed using the following code snippet.
↔️Median JavaScript Bridge
Run the following Median JavaScript Bridge command to share the screen content
median.socialShare.instagram.shareToFeed(blob);
Info
for iOS, Instagram no longer supports direct sharing to feed and will rather present the OS share dialog
Sharing to story or reels
You can share an image to Instagram story directly. This method allows you to optionally include a sticker attachment and caption.
↔️Median JavaScript Bridge
Run the following Median JavaScript Bridge command to share the screen content
median.socialShare.snapchat.share(blob, { attachment: stickerBlob, captionText: 'Caption for Snapchat' });
Updated 5 months ago