I have a turn-based match with two participants, A and B. It is currently A's turn. B quits out of turn by calling:
[match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit ... etc.
As far as A's Game Center app is concerned, the match with B is still in play – the match status is GKTurnBasedMatchStatusOpen
, and the match outcomes are GKTurnBasedMatchOutcomeNone
and GKTurnBasedMatchOutcomeQuit
respectively.
From the documentation, it appears that participant A should detect this and call:
participantA.matchOutcome = GKTurnBasedMatchOutcomeWon;
participantB.matchOutcome = GKTurnBasedMatchOutcomeQuit;
[self endMatchInTurnWithMatchData: ... etc.
However, there seems to be no notification for participantQuitOutOfTurnWithOutcome
, and periodically iterating through each match to end turns feels like a kludge.
What is the correct approach to ending these matches?
It has a nice solution :)
First of all you set a handler
[GKTurnBasedEventHandler sharedTurnBasedEventHandler].delegate = self;
After which, you will get the callbacks
handleInviteFromGameCenter: handleTurnEventForMatch:didBecomeActive: handleMatchEnded: handleTurnEventForMatch:didBecomeActive: handleTurnEventForMatch:didBecomeActive: player:receivedExchangeRequest:forMatch: player:receivedExchangeCancellation:forMatch: player:receivedExchangeReplies:forCompletedExchange:forMatch:
You need this method
handleMatchEnded:
To handle the match end on the opponent side.
Here is link to documentation https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/GameKit_Guide/ImplementingaTurn-BasedMatch/ImplementingaTurn-BasedMatch.html#//apple_ref/doc/uid/TP40008304-CH15-SW12
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With