I've been trying to create a sharing experience for our app where Instagram launches giving these two options:
Facebook has a pretty lean documentation about it. I tried all the possible permutations using the UIDocumentInteractionController. I tried using as uti
com.instagram.photo
and com.instagram.video
with the ig
extension but I keep getting the standard sharing popover instead of launching Instagram directly. Tried also com.instagram.exclusivegram
with igo
but that seems to be supposed to trigger the standard popover anyway.
Latest code:
func shareVideo(_ filePath: String) {
let url = URL(fileURLWithPath: filePath)
if(hasInstagram()){
let newURL = url.deletingPathExtension().appendingPathExtension("ig")
do {
try FileManager.default.moveItem(at: url, to: newURL)
} catch { print(error) }
let dic = UIDocumentInteractionController(url: newURL)
dic.uti = "com.instagram.photo"
dic.presentOpenInMenu(from: self.view.frame, in: self.view, animated: true)
}
}
The only way to get to the screen illustrated above is to save first the video in the library and then use the undocumented hook
instagram://library
passing the assetlocalIdentifier
. Don't forget to addinstagram
query scheme in theinfo.plist
.Try this :-
I am currently sharing my last saved video by this:-