FBSDKShareDialog 在视频共享的情况下不出现

FBSDKShareDialog not appearing in case of video share

我正在做一个项目,我需要在 Facebook 上一起分享一张图片和一段视频,但遇到了未定义的行为。

Issue: When I am trying to share a video using FBSDKShareMediaContent class (using below code), the FBSDKShareDialog is not appearing, but it appears when I share only an image.

我的代码:

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)

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

请帮忙。

我找到的解决方案是,根据共享视频的 Facebook guidelines,我分配的 url 路径是错误的。

The video URL videoURL must be an asset URL. You can get a video asset URL e.g. from UIImagePickerController.

查看 link 内的视频分享部分。

更新:

使用选择器或文档目录路径一起共享图像、视频的最终解决方案,这可行。

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