Unable to get post id after sharing photos with Facebook using ios app (Swift and FBSDK4.0.1)

I am writing an iOS photo sharing application.

Using Swift Technology and FBSDK 4.0.1

I found that sharing photos with FBSDKShare Photo Content () CANNOT get back the message id from the result object in the FBSDKSharingDelegateinside of the method didCompleteWithResults.
The result object contains an empty string:

[:]

However, sharing FBSDKShare URLs with a Content Contents () link can return a message identifier from a result object. something like that:

[postId: 10000844250000_146108069750000]


Part of my main code:

  • Image controller ( UIImagePickerControllerDelegate, UINavigationControllerDelegate)

    func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
    
    var theImage:UIImage = info[UIImagePickerControllerOriginalImage] as! UIImage
    uploadImage.image = theImage
    self.dismissViewControllerAnimated(false, completion: nil)
    }
    


  1.  @IBAction func postButtonClick(sender: AnyObject) {
    
       let photoContent = FBSDKSharePhotoContent()
    
       let photo : FBSDKSharePhoto = FBSDKSharePhoto()
       photo.image = uploadImage.image
       photo.userGenerated = true
    
       photoContent.photos = [photo]
    
       FBSDKShareDialog.showFromViewController(self, withContent: photoContent, delegate:self)
    }
    
  2. Facebook FBSDKSharingDelegate

     func sharer(sharer: FBSDKSharing!, didCompleteWithResults results: [NSObject: AnyObject])
     {
        println("sharer didCompleteWithResults, results.count\(results.count)")
        println(results)
        // still cannot get post id from photo upload
     }
    
     func sharer(sharer: FBSDKSharing!, didFailWithError error: NSError!) {
    
        println("sharer NSError")
        println(error.description)
    
     }
    
     func sharerDidCancel(sharer: FBSDKSharing!) {
    
        println("sharerDidCancel")
    
     }
    

.

+4
1
    let photo = FBSDKSharePhoto()
    photo.image = chosenImage
    photo.isUserGenerated = false
    let photoContent = FBSDKSharePhotoContent()
    photoContent.photos = [photo]
    let shareApiInstance = FBSDKShareAPI()
    shareApiInstance.message = "customized facebook content"
    shareApiInstance.shareContent = photoContent
    shareApiInstance.delegate = self
    shareApiInstance.share()

//

func sharer (_ sharer: FBSDKSharing!, didCompleteWithResults: [AnyHashable: Any]!) {
      print ( " " )

    let resultsInfo = results as! [String : Any]
    print(resultsInfo["postId"] as! String)
}

func sharer(_ sharer: FBSDKSharing!, didFailWithError error: Error!) {
    print("sharer NSError")
    print(error.localizedDescription)
}

func sharerDidCancel(_ sharer: FBSDKSharing!) {
    print("sharerDidCancel")
}

postId.

0

All Articles