Facebook Share Dialog Response Returning Nil for the Post ID

223 Views Asked by At

I'm trying to get the Facebook SDK up and running for my application, however, I've run into a problem. I've successfully gotten the sign in using Facebook functionality going, as well as the post functionality using the FacebookCore, FacebookShare, and FacebookLogin cocoa libraries. However, whenever I go to share the post with a completion handler, when I print the post id, it's returning nil. Here is my code for the post:

let image = testImage
    let photo = Photo(image: image, userGenerated: true)
    let sharePhotoContent = PhotoShareContent(photos: [photo])
    let dialog = ShareDialog(content: sharePhotoContent)

    dialog.mode = .native
    dialog.failsOnInvalidData = true

    dialog.completion = {

        (result) in

        print(result)

        switch(result) {
        case .success(let contentResponse):
            print("Success the post went through")
            print(contentResponse.postId)
        case .cancelled:
            print("Cancelled by user")
        case .failed(let error):
            print(error.localizedDescription)
        }

    }
    dialog.presentingViewController = self
    do {
        try dialog.show()
    } catch {
        print(error.localizedDescription)
    }

Any help would be extremely appreciated. Thanks!

0

There are 0 best solutions below