Reputation: 59
I am looking for a way to share a video of my application on Facebook. I installed the SDK to facebook and followed the instructions but I do not understand why I can not share my video.
let fbVideo:FBSDKShareVideo = FBSDKShareVideo()
fbVideo.videoURL = url
let content: FBSDKShareVideoContent = FBSDKShareVideoContent()
content.video = fbVideo
FBSDKShareDialog.showFromViewController(self, withContent: content, delegate: self)
I have one error with the parameter delegate :
Cannot convert value of type 'ShareViewController' to expected argument type 'FBSDKSharingDelegate!'
Note that I am in my class ShareViewController.
There are no other means to share a video on facebook ? thank you
Upvotes: 0
Views: 1279
Reputation: 3476
You have to implement FBSDKSharingDelegate
protocol and it's methods.
class ViewController: UIViewController ,FBSDKSharingDelegate{
//add following methods to the class:
func sharer(_ sharer: FBSDKSharing!, didCompleteWithResults results: [AnyHashable : Any]!) {
print("Completed");
}
func sharer(_ sharer: FBSDKSharing!, didFailWithError error: Error!) {
print("Failed with error : \(error.localizedDescription)");
}
func sharerDidCancel(_ sharer: FBSDKSharing!) {
print("Cancelled")
}
}
Upvotes: 0
Reputation: 6714
The method showFromViewController:withContent:delegate:
expects the delegate argument to be of type FBSDKSharingDelegate
. You are providing a value of type ShareViewController
not FBSDKSharingDelegate
which means said view controller does not conform to that type. You would need to make your view controller to conform to type FBSDKSharingDelegate
. As an example:
class ShareViewController: UIViewController, FBSDKSharingDelegate {
// code
}
Or pass in another object that conforms to type FBSDKSharingDelegate
.
Upvotes: 1