0

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!

  • Value of result is also nil or getting something? – shivi_shub Jul 23 '18 at 15:36
  • @shivi_shub The value of the result is not nil and is properly showing success, canceled, or failed. Only the post ID is nil. –  Jul 23 '18 at 15:47
  • I think post_id is only returned if the user is logged into your Facebook app and has granted the publish_actions permission. – shivi_shub Jul 23 '18 at 15:57
  • @shivi_shub but the user has already signed in and given permissions. –  Jul 23 '18 at 16:46

0 Answers0