Instagram Video iPhone Hook
I came up with the idea to allow my app to accept the instagram:// URL schema. The hook from Flipagram opened up in my app as the following:
instagram://library?AssetPath=assets-library%3A%2F%2Fasset%2Fasset.mp4%3Fid%3D8864C466-A45C-4C48-B76F-E3C421711E9D%26ext%3Dmp4&InstagramCaption=Some%20Preloaded%20Caption
The undocumented iPhone hook that allows you to automatically select assets from the iPhones photo roll, and preload a caption for the video. This should give you the same user experience that Flipagrams app has with sharing a video to Instagram.
NSURL *videoFilePath = ...; // Your local path to the video
NSString *caption = @"Some Preloaded Caption";
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeVideoAtPathToSavedPhotosAlbum:[NSURL URLWithString:videoFilePath] completionBlock:^(NSURL *assetURL, NSError *error) {
NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",[assetURL absoluteString].percentEscape,caption.percentEscape]];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
}];
Works great!
Update:
Instagram has removed the ability to pass the caption to their app. The best solution now it to just copy the desired caption to the paste board.
Instagram hooks pre-select media issue
instagram://library?AssetPath=\(assetsLibraryUrl)
stopped working a while ago. Instagram developers probably moved to Photos framework and no longer use the AssetsLibrary.
Having this assumption I tried several other parameter names and found that instagram://library?LocalIdentifier=\(localID)
where localId
is the localIdentifier
of your PHAsset
works for now.
This is still as undocumented as it was so it can break in any future version of the Instagram.
Related Topics
In iOS, How to Create a Button That Is Always on Top of All Other View Controllers
How to Throttle Search (Based on Typing Speed) in iOS Uisearchbar
Multiple Uilabels Inside a Self Sizing Uitableviewcell
Document Directory Path of Xcode Device Simulator
How to Get the Font Name from an Otf or Ttf File
In iOS 12, When Does the Uicollectionview Layout Cells, Use Autolayout in Nib
How to Simultaneously Satisfy Constraints - No Constraints in Place
Differencebetween Pan and Swipe in iOS
iOS 7 Status Bar Collides with Navigationbar
Get Device Location (Only Country) in iOS
How to Use Avfoundation to Crop a Video
What Does Addchildviewcontroller Actually Do
Creating a Uiimage from a Uicolor to Use as a Background Image for Uibutton
My App Was Just Rejected for Using the Ad Support Framework. Which Library Is Responsible
Uiview Hide/Show with Animation
Remove Separatorinset on iOS 8 Uitableview for Xcode 6 iPhone Simulator