Is it possible to share a video on Instagram without saving it to the user's Camera Roll?
this is what i tried so far:
let instagramURL = URL(string: "instagram://app")!
if (UIApplication.shared.canOpenURL(instagramURL)) {
self.documentController = UIDocumentInteractionController(url: videoURL)
self.documentController.delegate = self
self.documentController.uti = "com.instagram.exlusivegram"
self.documentController.presentOpenInMenu(from: self.view.frame, in: self.view, animated: true)
} else {
print(" Instagram isn't installed ")
}
videoURL
is the URL of the video i saves in the Documents folder.
if I save the URL with Instagram.igo
at the end, then when i choose Instagram to share it opens like this:
if I save the video with .mov at the end, it seems that Instagram share opens with a photo (like video thumbnail) and not a video.
Instagram app for Android and iPhoneTap below the photo or video in Feed. Tap Add post/video/reel to your story. Tap in the bottom right. Tap Share.
Typically, Instagram won't let you post if you're violating the guidelines, your content is stolen/copyrighted, you're spamming, or the video or image format is not supported. Otherwise, it's your poor internet connection that's stopping you from posting.
Instagram app for Android and iPhone. Tap at the top to view your phone's library. Tap Post, then tap . Select up to 10 photos and videos from your phone's library.
You can get a link to photos and videos that are shared on Instagram. If the account that posted the content is set to private, any links you share can only be seen by followers of that account.
What exactly you did wrong is difficult to determine, but I'll try to address where you might have been wrong.
First of all make sure that the videoURL is defined locally. When I wrote an app posting to Instagram, I first defined the path with file manager, like:
let tempDirectory = FileManager().temporaryDirectory
var postingPath = tempDirectory.appendingPathComponent("postingVideo")
postingPath = postingPath.appendingPathExtension("igo")
I then wrote the movie into this directory and almost have the same code as you. Do take into consideration that you need to create the igo folder and then save the movie into this folder. If you try to refer to the folder you have the movie in, your app will not read the movie file and nothing will be posted. When it is a movie file from the photo library, use an AVExportSession and export it to the postingPath.
self.instagramController = UIDocumentInteractionController.init(url: postingPath)
self.instagramController.uti = "com.instagram.exclusivegram"
self.instagramController.delegate = self
self.instagramController.presentOpenInMenu(from:
self.navigationItem.rightBarButtonItem!, animated: true)
However, you do need to make your class posting to instagram adhere to the UIDocumentInteractionControllerDelegate, otherwise you need cast self. You also need to include Social. I don't think you have done anything wrong in the second part of this post, because you would have gotten xcode errors and warnings.
I hope the first part can help you further, since I don't think the second part has given you problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With