Facebook SDK share always returns sharerDidCancel [duplicate]
Asked Answered
P

1

2

I'm trying to share a post with the Facebook SDK, but sharerDidCancel is always called, either if I share or cancel the post. Here is my code

- (void)shareFacebook {
    FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
    content.contentURL = [NSURL URLWithString:@"http://www.google.com"];
    [FBSDKShareDialog showFromViewController:view
                                 withContent:content
                                    delegate:self];
}

- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults :(NSDictionary*)results {
    NSLog(@"FB: SHARE RESULTS=%@\n",[results debugDescription]);
}

- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error {
    NSLog(@"FB: ERROR=%@\n",[error debugDescription]);
}

- (void)sharerDidCancel:(id<FBSDKSharing>)sharer {
    NSLog(@"FB: CANCELED SHARER=%@\n",[sharer debugDescription]);
}

This class implements the FBSDKSharingDelegate, in my Info.plist I already entered the FacebookAppID and FacebookDisplayName.

In my AppDelegate I have this method:

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

What I'm doing wrong? I exactly followed the Facebook SDK guide.

Thanks

Pinkney answered 7/7, 2015 at 21:5 Comment(0)
P
2

Solved, my error was in the AppDelegate method:

here is a link with the solution http://jitu1990.blogspot.it/2015/05/share-with-facebook-from-ios-app.html

And here is the code

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

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

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    return [ [FBSDKApplicationDelegate sharedInstance] application :application
             didFinishLaunchingWithOptions:launchOptions]
  }
Pinkney answered 8/7, 2015 at 15:40 Comment(1)
I also have implemented the same but still shareDidCancel is called always...Safeconduct

© 2022 - 2024 — McMap. All rights reserved.