Facebook SDK 总是分享 returns sharerDidCancel

Facebook SDK share always returns sharerDidCancel

我正在尝试与 Facebook SDK 共享 post,但无论是共享还是取消 post,总是会调用 sharerDidCancel。 这是我的代码

- (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]);
}

这个class实现了FBSDKSharingDelegate,在我的Info.plist我已经输入了FacebookAppID和FacebookDisplayName。

在我的 AppDelegate 中我有这个方法:

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

我做错了什么?我完全遵循了 Facebook SDK 指南。

谢谢

已解决,我的错误在 AppDelegate 方法中:

这里有一个 link 的解决方案 http://jitu1990.blogspot.it/2015/05/share-with-facebook-from-ios-app.html

这是代码

- (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]
  }