FBSDKShareDialog取消应该发布

我在代码中创build了一个FBSDKShareDialog

- (void)shareWithFacebookDialog; { FBSDKShareLinkContent* content = [[FBSDKShareLinkContent alloc] init]; content.contentURL = [NSURL URLWithString:@"Path Redacted"]; content.contentTitle = @"Title Redacted"; content.contentDescription = @"Description Redacted"; FBSDKShareDialog* dialog = [[FBSDKShareDialog alloc] init]; [dialog setMode:FBSDKShareDialogModeNative]; [dialog setShareContent:content]; [dialog setDelegate:self]; [dialog setFromViewController:self]; [dialog show]; } 

对话框启动并且所有的信息都是正确的

在这里输入图像说明

但是一旦点击“发布”,对话框closures,取消委托被调用。

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

有没有人看过这个? find了一个方法来克服它?

用这个replace你的代码

 - (void)shareWithFacebookDialog; { FBSDKShareLinkContent content = [[FBSDKShareLinkContent alloc]init]; content.contentURL = [NSURL URLWithString:@"https://www.google.com"]; content.contentTitle = @"ContentTitle"; content.contentDescription = @"ContentDescription"; [FBSDKShareDialog showFromViewController:self withContent:content delegate:self]; } 

告诉我,如果它的作品。

当我尝试在login后立即调用方法时,发生了这种情况。

 FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; [login logInWithPublishPermissions:@[@"publish_actions"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { if (error || result.isCancelled) { } else { [self shareWithFacebookDialog]; } }]; 

它工作,如果我只是调用它没有login(应该已经有有效的令牌)。

 if ([FBSDKAccessToken currentAccessToken]) { [self shareWithFacebookDialog]; } 

我有同样的问题: Facebook的SDK共享总是返回sharerDidCancel

我的错误是在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] } 

对于Facebook SDK v4.5 +,试试这个:

Objective-C的

 FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init]; content.contentURL = [NSURL URLWithString:@"http://developers.facebook.com"]; [FBSDKShareDialog showFromViewController:self withContent:content delegate:self]; 

迅速

 let content = FBSDKShareLinkContent() content.contentURL = URL(string: "http://developers.facebook.com") FBSDKShareDialog.show(from: self, with: content, delegate: self)