游戏邀请对话框有错误

时间:2015-06-05 07:34:18

标签: ios facebook-graph-api

我想向我的facebook好友发送游戏请求。但是当我使用 FBSDKGameRequestContent 时,会显示一个GameRequestDialog,即弹出菜单。 我的代码就在这里..

FBSDKGameRequestContent *gameRequestContent = [[FBSDKGameRequestContent alloc] init];
// Look at FBSDKGameRequestContent for futher optional properties
FBSDKGameRequestDialog *dialog = [[FBSDKGameRequestDialog alloc]init];
dialog.delegate = self;
dialog.content = gameRequestContent;
gameRequestContent.message = @"Become a Ninja!!!";
gameRequestContent.title = @"NinjaPan";
dialog.delegate = self;
dialog.content = gameRequestContent;
[dialog show];

和对话框显示错误

错误:参数app_id是必需的

请帮助我..

2 个答案:

答案 0 :(得分:0)

在发送游戏请求之前,检查您是否已拥有有效令牌:

if ([FBSDKAccessToken currentAccessToken]) {

    FBSDKGameRequestContent *gameRequestContent = [[FBSDKGameRequestContent alloc] init];
    ...
   FBSDKGameRequestDialog* dialog = [[FBSDKGameRequestDialog alloc] init];
   dialog.content = gameRequestContent;
   ...
   [dialog show];

}

答案 1 :(得分:-1)

这是FB的例子:

FBSDKGameRequestContent *gameRequestContent = [[FBSDKGameRequestContent alloc] init];
// Look at FBSDKGameRequestContent for futher optional properties
gameRequestContent.message = @"YOUR_MESSAGE_HERE";
gameRequestContent.title = @"OPTIONAL TITLE";

// Assuming self implements <FBSDKGameRequestDialogDelegate>
[FBSDKGameRequestDialog showWithContent:gameRequestContent delegate:self];

FBSDKGameRequestContent *gameRequestContent = [[FBSDKGameRequestContent alloc] init];
gameRequestContent.message = @"Take this bomb to blast your way to victory!";
gameRequestContent.to = @[@"RECIPIENT_USER_ID"];
gameRequestContent.objectID = @"YOUR_OBJECT_ID";

// Assuming self implements <FBSDKGameRequestDialogDelegate>
[FBSDKGameRequestDialog showWithContent:gameRequestContent delegate:self];

此外,文档说:......这些示例假设发件人已经对应用程序进行了身份验证。

谢谢Hiren。