Sharad Chauhan
Sharad Chauhan

Reputation: 4891

How to get post id from FacebookShare PostSharingResult

I am sharing video on facebook using GraphSharer and looking for post id in the share completion.

But I am not able to fetch it.

sharer.completion = { result in
                        // Handle share results
                        print("Share results : \(result)")

                    }

I am getting this on my logs :

Share results : success(FacebookShare.PostSharingResult(dictionary: ["video_id": "1455433997844989", "completionGesture": "post"]))

So i tried these but didn't work :

  1. let dict = result as! [String:Any]
  2. result[""]

    but getting error ContentSharerResult has no subscript member

Any idea how to get the value video_id from this result ? Any help would be appreciated.

Thanks!

Upvotes: 0

Views: 209

Answers (1)

Sharad Chauhan
Sharad Chauhan

Reputation: 4891

After some more workarounds I finally got the solution for my problem. For anyone in future wants to fetch post id.

sharer.completion = { result in
            // Handle share results
            print("Share results : \(result)")
            switch result{
            case .success(let shareResult):
                print(shareResult["video_id"])  // Your post id
                break
            case .cancelled:
                break
            case .failed(let Error):
                print(Error)
                break
            }

Upvotes: 2

Related Questions