dimanche 12 juin 2016

GKTurnBasedMatch how to accept a new match invitation


What is the correct way to programmatically accept a match invitation with GameKit's standard user interface?

I am seeing an expectedState="Invited" foundState="Active" exception

Optional(Error Domain=GKErrorDomain Code=22 
"The requested operation could not be completed because the specified participant is invalid." 
UserInfo={GKServerStatusCode=5097, 
NSLocalizedDescription=The requested operation could not be completed because the specified participant is invalid., 
NSUnderlyingError=0x14fa2cf70 {
Error Domain=GKServerErrorDomain Code=5097 "status = 5097, 
Unexpected slot state expectedState="Invited" foundState="Active"

The exception occurs under the following scenario:
Player 1 - Creates a new match with player 2
Player 1 - Makes the first move
Player 2 - Attempts to load data from the turn based match & accept the match invitation.

I am using iOs' standard user interface for match making. GKTurnBasedMatchmakerViewController

Requesting a new match

let matchRequest = GKMatchRequest()
matchRequest.minPlayers = 2
matchRequest.maxPlayers = 2
matchRequest.defaultNumberOfPlayers = 2
matchRequest.inviteMessage = "Play BoxTheDots with me"
matchRequest.recipientResponseHandler = self.matchMaker?.recipientResponse

let matchView = GKTurnBasedMatchmakerViewController(matchRequest: matchRequest)
self.presentViewController(matchView, animated: true, completion: nil)
matchView.turnBasedMatchmakerDelegate = self.matchMaker?.matchViewController

Player 1 after making the first turn enter image description here

Player 2 before loading match from player 1 enter image description here


Aucun commentaire:

Enregistrer un commentaire