视频共享时不显示FBSDKShareDialog

时间:2017-07-11 11:51:47

标签: ios swift facebook facebook-share

我正在开展一个项目,我需要在Facebook上共享图像和视频,但面临未定义的行为。

  

问题:当我尝试使用FBSDKShareMediaContent课程(使用下面的代码)分享视频时, FBSDKShareDialog没有出现但是当它出现时我只分享了一张图片

我的代码:

let photo: FBSDKSharePhoto = FBSDKSharePhoto.init(image: imageToShare, userGenerated: true)

let vid: FBSDKShareVideo = FBSDKShareVideo.init(videoURL: URL(string:vidUrl!.path))

 //  FBSDKShareDialog not appearing in this case 
let shareContent: FBSDKShareMediaContent = FBSDKShareMediaContent()
shareContent.media = [photo, vid]

/*
// FBSDKShareDialog appearing 
let shareContent: FBSDKShareMediaContent = FBSDKShareMediaContent()
shareContent.media = [photo]  */


FBSDKShareDialog.show(from: self.getCurrentViewController(), with: shareContent, delegate: nil)

视频网址: file:///var/mobile/Containers/Data/Application/2E0E48B7-30E5-4567-8C0B-ACAC100AE389/Documents/AppName/1499773278.555753.mp4

请帮忙。

1 个答案:

答案 0 :(得分:1)

我发现的解决方案是,根据共享视频的Facebook guidelines,我分配的网址路径是错误的。

  

视频网址videoURL必须是资产网址。您可以获取视频资产网址,例如来自UIImagePickerController。

请参阅link内的视频分享部分。

<强>更新

使用选择器或文档目录路径共享图像,视频的最终解决方案,无论哪种方式都有效。

let shareText = "Upload video, image and text."
let vc = UIActivityViewController(activityItems: [shareText, vidUrl, imageToShare], applicationActivities: [])
present(vc, animated: true)