Share video to Instagram feed from iOS

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 asset localIdentifier. Don't forget to add instagram query scheme in the info.plist.

if UIApplication.shared.canOpenURL("instagram://app") { // has Instagram
    let url = URL(string: "instagram://library?LocalIdentifier=" + videoLocalIdentifier)

    if UIApplication.shared.canOpenURL(url) {
        UIApplication.shared.open(url, options: [:], completionHandler:nil)
    }
}

Try this :-

I am currently sharing my last saved video by this:-

    let fetchOptions = PHFetchOptions()
    fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
    let fetchResult = PHAsset.fetchAssets(with: .video, options: fetchOptions)
    if let lastAsset = fetchResult.firstObject {
        let localIdentifier = lastAsset.localIdentifier
        let u = "instagram://library?LocalIdentifier=" + localIdentifier
        let url = NSURL(string: u)!
        if UIApplication.shared.canOpenURL(url as URL) {
            UIApplication.shared.open(URL(string: u)!, options: [:], completionHandler: nil)
        } else {

            let urlStr = "https://itunes.apple.com/in/app/instagram/id389801252?mt=8"
            if #available(iOS 10.0, *) {
                UIApplication.shared.open(URL(string: urlStr)!, options: [:], completionHandler: nil)

            } else {
                UIApplication.shared.openURL(URL(string: urlStr)!)
            }
        }

    }