How to share video on Facebook in Swift?

511 Views Asked by At

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

There are 1 best solutions below

0
On
[FBSDKShareDialog showFromViewController:withContent:delegate:]

You can use one delegate method to call the dialog view