GKTurnBasedMatch

I am working on a two player turn based game. I'm struggling to undestand the informaiton flow of starting a match, exchanging moves and saving status to the local device and to Game Center. However while looking at the GameCenter documents at apple.com they all seem to lead to depricated functions.


Is there and example using non-depricated functions?


When starting a match, when will the remote player be notified of the match starting?


When ending a turn and sending data, do I send all of the game data or just the current move?


Do I have to have two seperate devices with seperate phone numbers or just apple ids? I have two apple id's, one of my phone and one on my iPad, but I can only invite my phone from my ipad because the ipad does not have a seperate phone number.


I have more questions, but for now if I could just get the match to be started on both devices it would be a good start. Any help with that would be appreciated.

Replies

I am unfamiliar with a turn based match. But with a real time match (and I think they are similar if not identical) there are two avenues you need to cover (the inviter and the invitee). In one, you just present a GKMatchmakerViewController to invite someone; you use that to invite; it returns to a matchmakerViewController:didFindMatch: and your done. In the other you get invited through Game Center and you 'accept'; you get a call to player:didAcceptInvite: you display a GKMatchmakerViewController and that then returns to a matchmakerViewController:didFindMatch: your done.


see:

https://developer.apple.com/documentation/gamekit/gkmatchmakerviewcontroller?language=objc

Thanks for the reply, I've read and followed that documentation. Currently I can send an invite from one device to the other and it shows up as a message. When I touch the invite a popup appears saying retreiving and then goes away with nothing happening. I assume there is some action I need to take in the code to process and activate this but I am unclear on that. What needs to be done and where in the documentation is it?

It may be different for a turn based game then for a real time match. But in a real time match:

https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/GameKit_Guide/Matchmaking/Matchmaking.html#//apple_ref/doc/uid/TP40008304-CH9-SW1

it says......

Processing Invitations from Other Players

When a player accepts an invitation from another player, your game is launched (if necessary) and an invitation is delivered to your game. Your game receives this invitation by registering a listener to the local player. Create a class that implements the

GKLocalPlayerListener
protocol. Inside of your class, implement the
player:didAcceptInvite:
method to handle the invitation.


I respond to a call to player:didAcceptInvite with:

GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithInvite:invite];

and present that. The invited player then responds within the app and generates a call to:

matchmakerViewController:didFindMatch:

and the match starts.


I have an update, if I retrieve the recent players list and include one of the players in the recipients member variable in the GKMatchRequest I get a notification about the match on the second device. But if I don't populate it the match request is not delivered.

Thanks for the update.