IOS 返回 FacebookShare 错误 'reserved'
IOS FacebookShare Error 'reserved' being returned
我尝试搜索但找不到答案。我写了一个应用程序,我正在尝试将内容分享到 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)
}
}
想通了。
这一行...
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)
有相同的 reserved
错误,但在使用 VideoShareContent
时。花了5个小时才找到问题,终于找到了。真的希望有人觉得这也有帮助。
解决方案:当您从 UIImagePickerController
委托方法的 info
参数中检索视频的 url
时,确保使用关键 "UIImagePickerControllerReferenceURL"
.
示例:
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)
}
}
}
附加信息:最初我没有使用这个键"UIImagePickerControllerReferenceURL"。为什么:它是 deprecated。根据 Apple 的说法,您应该改用 UIImagePickerControllerPHAsset。但是那里的 url 也有 returns reserved
错误。另一个尝试是使用密钥"UIImagePickerControllerMediaURL"
,但它也没有成功。
我尝试搜索但找不到答案。我写了一个应用程序,我正在尝试将内容分享到 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)
}
}
想通了。
这一行...
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)
有相同的 reserved
错误,但在使用 VideoShareContent
时。花了5个小时才找到问题,终于找到了。真的希望有人觉得这也有帮助。
解决方案:当您从 UIImagePickerController
委托方法的 info
参数中检索视频的 url
时,确保使用关键 "UIImagePickerControllerReferenceURL"
.
示例:
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)
}
}
}
附加信息:最初我没有使用这个键"UIImagePickerControllerReferenceURL"。为什么:它是 deprecated。根据 Apple 的说法,您应该改用 UIImagePickerControllerPHAsset。但是那里的 url 也有 returns reserved
错误。另一个尝试是使用密钥"UIImagePickerControllerMediaURL"
,但它也没有成功。