我试过搜索但找不到答案。我写了一个应用程序,我正在尝试分享内容到Facebook。基本上我想分享一个URL,也许是一个引用或标题。
我一直收到一个名为'reserved'的错误,但我不确定它是什么意思或如何修复它。任何帮助都会很棒!
func fbClick() {
let content = LinkShareContent(url: URL(string: "www.google.com")!)
showShareDialog(content, mode: .native)
}
func showShareDialog<C: ContentProtocol> (_ content: C, mode: ShareDialogMode = .automatic) {
let dialog = ShareDialog(content: content)
dialog.presentingViewController = self
dialog.mode = mode
do {
try dialog.show()
} catch (let error) {
self.view.makeToast("Invalid share content. Failed to present share dialog with error \(error)", duration: 3.0, position: .top)
}
}
答案 0 :(得分:1)
想出来。
这一行...
let content = LinkShareContent(url: URL(string: "www.google.com")!)
应该是这样的......
let content = LinkShareContent(url: NSURL(string: "https://www.google.com")! as URL)
或者像这样
let content = LinkShareContent(url: NSURL(string: "https://www.google.com")! as URL, quote: quote)
答案 1 :(得分:1)
使用reserved
时出现相同的VideoShareContent
错误。花了5个小时找到问题,终于找到了。真的希望有人发现这也很有帮助。
解决方案:当您从url
委托方法的info
param检索视频的UIImagePickerController
时,请确保使用密钥{{1 }}
示例:
"UIImagePickerControllerReferenceURL"
其他信息:最初我没有使用此密钥“UIImagePickerControllerReferenceURL”。为什么:它是deprecated。根据Apple的说法,你应该使用UIImagePickerControllerPHAsset代替。但是那里的url也会返回func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any]) {
picker.dismiss(animated: true)
if let videoURL = info["UIImagePickerControllerReferenceURL"] as? URL {
let video = Video(url: videoURL)
let content = VideoShareContent(video: video)
do {
try ShareDialog.show(from: self, content: content)
} catch {
print(error)
}
}
}
错误。另一种尝试是使用键reserved
,但它也没有成功。