Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS Facebook SDK : what wrong with sharerDidCancel:(id<FBSDKSharing>)sharer delegate?

I use facebook sdk worked well except for delegate "sharerDidCancel:(id)sharer".

When i cancel my share with native dialog FB app, the delegate "sharer:(id)sharer didCompleteWithResults:(NSDictionary *)results" always called ? So i can't handle my users when they post or cancel the dialog share, is this a bug of Facebook SDK for IOS ?

Thanks for any helping!

like image 227
NguyenDark Avatar asked May 12 '15 08:05

NguyenDark


People also ask

What is the latest version of Facebook SDK for iOS?

The current version of the Facebook SDK for iOS is version 14.1. 0.

What is Facebook SDK for iOS?

The Facebook SDK enables: Facebook Login - Authenticate people with their Facebook credentials. Share and Send dialogs - Enable sharing content from your app to Facebook. App Events - Log events in your application.

Does Facebook SDK use IDFA?

The Facebook SDK includes code to access Apple's Advertising Identifier (IDFA), but that code is only executed in certain situations.


2 Answers

I faced same issue during sharing in iOS 11. I have just changed native FB dialog to web dialog. As below:

Use below method:

dialog.mode = FBSDKShareDialogMode.feedWeb

instead of

dialog.mode = FBSDKShareDialogMode.native

Below is my code.It's work fine for me.

let content: FBSDKShareLinkContent = FBSDKShareLinkContent()
content.quote = "My Text"
content.contentURL = NSURL(string: String(format:"My Url"))! as URL!
let dialog: FBSDKShareDialog = FBSDKShareDialog()
dialog.fromViewController = self
dialog.shareContent = content
dialog.delegate = self
dialog.mode = FBSDKShareDialogMode.feedWeb
dialog.show()
like image 199
Sonam Maniar Avatar answered Oct 13 '22 01:10

Sonam Maniar


I've just been digging through the Facebook SDK docs and found this:

sharer:didCompleteWithResults: when the user successfully shares. Furthermore there will also be a postId key in the results dictionary if the user gave the app publish_actions permissions. If that user has not logged in with Facebook Login, this method will also be called if the user clicks on Cancel.

So, unless you're logged in, checking cancel won't work (which is rubbish). Looks like you might be able to give some permissions and then check the postId though.

like image 28
GeordieMatt Avatar answered Oct 13 '22 01:10

GeordieMatt