3
votes

I'm implementing the share dialog using the Facebook SDK for iOS. Everything works fine except for the callback. This is the function that displays the dialog:

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
    content.contentURL = <my content url>;
    content.contentTitle = <my title>;
    content.contentDescription = my description;
    content.imageURL = <my image url>;
    [FBSDKShareDialog showFromViewController:self
                                 withContent:content
                                    delegate:self];

The view controller implements the FBSDKSharingDelegate and the three required methods:

- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results;

- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error;

- (void)sharerDidCancel:(id<FBSDKSharing>)sharer;

Basically I have to detect if users pressed the cancel button because I give them a reward only if they effectively share the content. The problem is that even if I press the cancel button the only callback that is invoked is:

- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results;

and not

- (void)sharerDidCancel:(id<FBSDKSharing>)sharer;

as expected. Furthermore using iOS8 the variable results is empty if the cancel button is pressed, otherwise it contains the post_id, but this does not happen with iOS7, where the result is always empty.

What am I doing wrong? What am I supposed to do to have the sharerDidCancel callback working properly?

Thanks for any help!

1
“because I give them a reward only if they effectively share the content” – you are not allowed to reward users for sharing. Please go read Platform Policy – 4.5 says, “Only incentivize a person to log into your app, enter a promotion on your app’s Page, or check-in at a place. Don’t incentivize other actions.”CBroe
Brilliant! Thank you very much for that I didn't know it. Anyway the problem now persist. Any idea how could I resolve it?Prem
@Prem, I am also facing the same issue. do you have any solution for this?user2526811
Nope. It's only working on iPhone 6 or greater actually. I could not find a way to have it working on iPhone 5s / 5 / 4s etc...Prem
If you use the FBSDKShareDialog display mode as FBSDKShareDialogModeWeb,It can solve this problem.Hope it helpful.fiona zhou

1 Answers

0
votes

Try entering this to your appdelegate. It worked for me to call the right delegate but the result dictionary is still empty and I can't get the post_id.

#import <FBSDKCoreKit/FBSDKCoreKit.h>

- (void)applicationDidBecomeActive:(UIApplication *)application {
  [FBSDKAppEvents activateApp];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  return [[FBSDKApplicationDelegate sharedInstance] application:application
                              didFinishLaunchingWithOptions:launchOptions];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
  return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                    openURL:url
                                          sourceApplication:sourceApplication
                                                 annotation:annotation];
}