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!
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];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.