首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FBSDKShareDialog回调iOS

FBSDKShareDialog回调iOS
EN

Stack Overflow用户
提问于 2015-06-04 22:39:18
回答 1查看 4.9K关注 0票数 5

当FBSDKShareDialog返回到您的应用程序(在用户创建完一个帖子之后)时,它的回调方法是什么?

这就是我要创建的对话框:

代码语言:javascript
复制
-(IBAction)post:(id)sender{
    FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
    content.contentURL = [NSURL URLWithString:self.spinShareURL];
    content.contentDescription=@"#spin";
    self.fromFacebook = true;

    [FBSDKShareDialog showFromViewController:self withContent:content delegate:nil];

}

我在某个地方读到有一个回调

代码语言:javascript
复制
-(void)dialogDidComplete:(FBSDKShareDialog *)dialog{
 }

但这对我没用。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-05 15:58:49

我在以下页面找到了解决方案:

http://jitu1990.blogspot.com/2015/05/share-with-facebook-from-ios-app.html

这是我的最后代码:

代码语言:javascript
复制
-(IBAction)post:(id)sender{
    FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
    content.contentURL = [NSURL URLWithString:self.spinShareURL];
    content.contentTitle= [NSString stringWithFormat: @"%@'s spin", self.username];
    content.contentDescription=@"#spin";
    self.fromFacebook = true;

    [FBSDKShareDialog showFromViewController:self withContent:content delegate:self];

}- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results
{
    NSLog(@"returned back to app from facebook post");
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
                                                    message:@"Posted!"
                                                   delegate:self
                                          cancelButtonTitle:nil
                                          otherButtonTitles:nil];
    [alert show];
    double delayInSeconds = 1.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        [alert dismissWithClickedButtonIndex:0 animated:YES];
    });
}

- (void)sharerDidCancel:(id<FBSDKSharing>)sharer
{
   NSLog(@"canceled!");
}

- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
    NSLog(@"sharing error:%@", error);
    NSString *message = @"There was a problem sharing. Please try again!";
    [[[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}
票数 14
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30655414

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档