2015-06-05 46 views
0
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。該對話框已打開,但我想在用戶點擊發送/取消後執行一些自定義功能。 我該怎麼做?Ios FBSDKGameRequestDialog發送取消方法事件

回答

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 
} 
+0

Thnkx烏拉圭回合的答案。你能舉出一個代碼樣本嗎?我嘗試過..但我斯塔克... :( – rohan

+0

它就像任何代表方法(UITableView有一些,UICollection也是如此)等等)你有什麼問題嗎?我不使用FaceBook API,但這應該是工作。 – Larme

+0

我嘗試過使用委託方法...但它不工作...我沒有在FB Api上工作... – rohan