I am trying to implement invitations to Game Center, and there is one thing that I donโt understand. Ok, I sent an invitation from one device to another. Then I have a UIAlertView on the receiver that asks me that I would like to accept or decline the invitation. when I accept it, it is processed as follows:
[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite) { // Insert application-specific code here to clean up any games in progress. if (acceptedInvite) { GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite] autorelease]; mmvc.matchmakerDelegate = self; [presentingViewController presentModalViewController:mmvc animated:YES]; } else if (playersToInvite) { GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease]; request.minPlayers = 2; request.maxPlayers = 4; request.playersToInvite = playersToInvite; GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease]; mmvc.matchmakerDelegate = self; [presentingViewController presentModalViewController:mmvc animated:YES]; } };
Ok, that's great, but what's next? the sending device is obviously waiting for some standard type of response, because it also shows a warning informing me that some invitations have not yet received an answer if I click "Play Now".
So how can I accept the invitation? What data (and how) should I send back? And what exactly should I do on the receiver side? Should the game begin immediately after clicking Accept, or should I release AlertView first and then click Play Now?
The Ray Wenderlich tutorial says that I have to choose the second method, but when you release the warning and click "Play Now", it turns out that the sending device is still waiting for an answer and I donโt know that I already accepted the invitation. if I click "Play Now", then, as I said above, it shows a warning saying that the application is waiting for a response. Therefore, if you have ever done this, please explain to me what to do. Thank you
Andrey Chernukha
source share