Share video to Instagram feed from iOS

前端 未结 3 1612
無奈伤痛
無奈伤痛 2021-02-04 08:23

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 i

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-04 08:53

    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)
        }
    }
    

提交回复
热议问题