Mirko
Mirko

Reputation: 187

Cannot conform to FBSDKSharingDelegate

I cannot conform my GameViewController to FBSDKSharingDelegate and I don't know why.

These are the function I think it need.

func sharer(sharer: FBSDKSharing, didCompleteWithResults results: [NSObject : AnyObject]) {
}
func sharer(sharer: FBSDKSharing, didFailWithError error: NSErrorPointer) {
}
func sharerDidCancel(sharer: FBSDKSharing) {
    NSLog("share cancelled")
}

Am I missing something?

Thank you in advance!

Upvotes: 2

Views: 2204

Answers (3)

Bobj-C
Bobj-C

Reputation: 5426

The following solved my issue:

    public func sharerDidCancel(_ sharer: FBSDKSharing!) {

}


public func sharer(_ sharer: FBSDKSharing!, didFailWithError error: Swift.Error!) {

}

public func sharer(_ sharer: FBSDKSharing!, didCompleteWithResults results: [AnyHashable : Any]!) {

}

Upvotes: 1

Here is my case for Swift 3

/*!
     @abstract Sent to the delegate when the sharer is cancelled.
     @param sharer The FBSDKSharing that completed.
     */
    public func sharerDidCancel(_ sharer: FBSDKSharing!) {

    }

    /*!
     @abstract Sent to the delegate when the sharer encounters an error.
     @param sharer The FBSDKSharing that completed.
     @param error The error.
     */
    public func sharer(_ sharer: FBSDKSharing!, didFailWithError error: Error!) {

    }

    /*!
     @abstract Sent to the delegate when the share completes without error or cancellation.
     @param sharer The FBSDKSharing that completed.
     @param results The results from the sharer.  This may be nil or empty.
     */
    public func sharer(_ sharer: FBSDKSharing!, didCompleteWithResults results: [AnyHashable : Any]!) {

    }

Upvotes: 0

Mirko
Mirko

Reputation: 187

Solved.

func sharer(sharer: FBSDKSharing!, didCompleteWithResults results: [NSObject: AnyObject]) {
    print(results)
}

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

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

Upvotes: 3

Related Questions