我们正尝试使用其共享API https://developers.facebook.com/docs/sharing
将视频上传到Facebook Stories我可以上传图片,没问题。视频似乎已上传,但最终显示带有视频图标的黑屏。
我们在iOS上使用AlamoFire提取文件,然后将其发送出去。
let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)
Alamofire.download(media[0]["url"]!, to: destination)
.downloadProgress { progress in
}
.responseData { response in
if response.error == nil, let filePath = response.destinationURL?.path {
PHPhotoLibrary.shared().saveVideo(filePath: filePath, albumName: "Loomly", completion: { (asset) in
// Clean up the tmp file otherwise error will be thrown on re-download
if FileManager.default.fileExists(atPath: (response.destinationURL?.path)!) {
try! FileManager.default.removeItem(atPath: (response.destinationURL?.path)!)
}
if asset == nil {
// present notification
}
if #available(iOS 10.0, *) {
pasteboard.setItems([["com.facebook.sharedSticker.backgroundVideo" : (asset?.localIdentifier)!, "com.facebook.sharedSticker.appID" : appID]],
options: [UIPasteboard.OptionsKey.expirationDate: expirationDate])
UIApplication.shared.open(facebookUrl!, options: [:], completionHandler: { (success) in
if success {
NotificationCenter
.default
.addObserver(self, selector:#selector(self.popAndReloadOnAppear), name:UIApplication.willEnterForegroundNotification, object: nil)
}
})
} else {
// Fallback on earlier versions - Since we are bumping minimum version to 10 we probably don't need this
}
}, accessDenied: {
DispatchQueue.main.async {
HUD.hide()
}
})
}
}
我希望其他人遇到这个问题并可能解决这个问题或有一些想法。我也有在Facebook开张的票。