iosswiftfacebook-share

IOS FacebookShare Error 'reserved' being returned


I've tried searching but could not find an answer. I have written an app and I am trying to share content to facebook. Basically I would like to share a URL and maybe a quote or title.

I keep getting an error called 'reserved' but I am not sure what it means or how to fix it. Any help would be great!

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)
    }
}

Solution

  • Figured it out.

    This line...

    let content = LinkShareContent(url: URL(string: "www.google.com")!)
    

    Should have been like this...

    let content = LinkShareContent(url: NSURL(string: "https://www.google.com")! as URL)
    

    or like this

    let content = LinkShareContent(url: NSURL(string: "https://www.google.com")! as URL, quote: quote)