Ios FBSDKGameRequestDialog发送取消方法事件

时间:2015-06-05 10:32:41

标签: ios facebook-graph-api

FBSDKGameRequestContent *content = [[FBSDKGameRequestContent alloc]init];
content.message = @"Great FB";
content.title = @"Invite Friends";
FBSDKGameRequestDialog *gameDialog = [[FBSDKGameRequestDialog alloc]init];
gameDialog.content = content;
gameDialog.frictionlessRequestsEnabled = YES;
gameDialog.delegate = self;
if ([gameDialog canShow]) {
   [gameDialog show];
}

我使用上面的代码来显示FBFriends。该对话框已打开,但我想在用户点击发送/取消后执行一些自定义功能。 我该怎么办?

1 个答案:

答案 0 :(得分:1)

您正在做:

gameDialog.delegate = self;

那么,为什么不使用委托方法(FBSDKGameRequestDialogDelegate):gameRequestDialogDidCancel:gameRequestDialog:didCompleteWithResults:了解用户是否已取消发送邀请?

Source

在YourCurrentClass.h中:

@interface YourCurrentClass : NSObject < FBSDKGameRequestDialogDelegate >

在YourCurrentClass.m中:

- (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog
didCompleteWithResults:(NSDictionary *)results
{
    //User has done something.
    //Check "results" and do something.
}

- (void)gameRequestDialogDidCancel:(FBSDKGameRequestDialog *)gameRequestDialog
{
    //User has cancelled
    //Do somathing
}

- (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog
didFailWithError:(NSError *)error
{
    //An error happened
    NSLog(@"Error: %@", error);
    //Do something
}