gpt4 book ai didi

ios - iOS 的 FBSDKShareDialog 回调

转载 作者:可可西里 更新时间:2023-11-01 04:13:34 24 4
gpt4 key购买 nike

FBSDKShareDialog 返回到您的应用程序时(用户创建完帖子后)的回调方法是什么?

这是我必须创建的对话框:

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

}

我在某处读到有回调

-(void)dialogDidComplete:(FBSDKShareDialog *)dialog{
}

但这对我不起作用。

最佳答案

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

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

这是我的最终代码:

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

关于ios - iOS 的 FBSDKShareDialog 回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30655414/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com