1
我正在開發cocos2dx
遊戲iOS
卡住了,我已經集成了Game Center
但是當我發出邀請好友發送者並沒有recive該接收機接受委託方法的要求或不沒有被調用的響應。我已經嘗試了所有的解決方案,但沒有什麼工作進一步如果有什麼不對的地方,我可以共享代碼:遊戲中心邀請
GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = minPlayers;
request.maxPlayers = maxPlayers;
request.inviteMessage = @"Your Custom Invitation Message Here";
request.inviteeResponseHandler = ^(NSString *playerID, GKInviteeResponse response)
{
if (response == GKInviteeResponseAccepted)
{
NSLog(@"DEBUG: Player Accepted: %@", playerID);
// Tell the infrastructure we are don matching and will start using the match
}
};
[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch* match, NSError *error) {
if (error)
{
//Invite has not been sent
NSLog(@"Invitation has not been sent");
}
else if (match != nil)
{
//whatever you want to do when the receiver accepts the invite
NSLog(@"Invitation has been sent with match object = %@",match);
}
}];
request.recipientResponseHandler= ^(GKPlayer *player, GKInviteeResponse response)
{
switch (response) {
case GKInviteeResponseAccepted:
{
}
break;
case GKInviteeResponseDeclined:
{
}
break;
case GKInviteeResponseFailed:
{
}
break;
case GKInviteeResponseIncompatible:
{
}
break;
case GKInviteeResponseUnableToConnect:
{
}
break;
case GKInviteeResponseNoAnswer:
{
}
break;
default:
break;
}
};
GKMatchmakerViewController *mmvc =
[[GKMatchmakerViewController alloc] initWithMatchRequest:request];
mmvc.matchmakerDelegate = self;
[viewController presentViewController:mmvc animated:YES completion:nil];
你是否收到任何GKInviteeResponse? – Striker