简体   繁体   中英

How to share video on Facebook in Swift?

I try to share video to Facebook but when dialog shown video doesn't appear.

func facebookShare(url: URL){
        guard let schemaUrl = URL(string: "fb://") else {
                    return //be safe
        }
        if UIApplication.shared.canOpenURL(schemaUrl) {

        let video = ShareVideo(videoURL: url)
        let content = ShareVideoContent()
        content.video = video
        let dialog = ShareDialog()
        dialog.shareContent = content
        dialog.delegate = self
        dialog.fromViewController = self
        dialog.mode = .automatic
        dialog.show()
            
        
        }else {
            print("app not installed")
        }

    }

here is my imagepicker functions

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        self.dismiss(animated: true, completion: nil)
        videoURL = info[UIImagePickerController.InfoKey.init(rawValue: "UIImagePickerControllerMediaURL")] as? URL
}
[FBSDKShareDialog showFromViewController:withContent:delegate:]

您可以使用一种委托方法来调用对话框视图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM