Facebook的SDK共享总是返回sharerDidCancel

我正在尝试与Facebook SDK共享post,但sharerDidCancel总是被调用,要么分享或取消post。 这是我的代码

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

这个类实现了FBSDKSharingDelegate,在我的Info.plist中我已经input了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方法中:

这里是解决scheme的链接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] }