关于检测您已被邀请参加基于回合的比赛:没有发送任何事件,但是当您从服务器查询您的比赛列表时,您会突然出现一个新的比赛(并且您的状态将被邀请)。(不过,收件人确实会收到 UIAlert 提示他们已收到邀请)
关于各种 API 函数是否/何时触发,我花了很多很多时间试图破译这些各种功能何时触发。我已经针对函数或文档打开了多个错误。这是我目前的笔记;这就是我在帮助程序类中组织所有委托函数的方式,指示它们应用到哪个侦听器以及导致它们触发的原因的注释。
你可以看到有几个我从来没有破译过。对此列表的任何其他输入/说明将不胜感激。
#pragma mark - specific to real-time matches
//this is for real-time matches only (but the docs don't say that)
-(void)player:(GKPlayer *)player didAcceptInvite:(GKInvite *)invite
#pragma mark - saved game listener (GKSavedGameListener)
//never fires. Theory: only fires if the SAME player tries to save the game from a different device while being the active player
-(void)player:(GKPlayer *)player didModifySavedGame:(GKSavedGame *)savedGame
//never fires. Theory: only fires if the SAME player tries to save the game from a different device while being the active player
-(void)player:(GKPlayer *)player hasConflictingSavedGames:(NSArray *)savedGames
#pragma mark - game launched via game center (GKLocalPlayerListener)
//DEPRECATED: This is fired when the user asks to play with a friend from the game center.app
-(void)player:(GKPlayer *)player didRequestMatchWithPlayers:(NSArray *)playerIDsToInvite
//This is fired when the user launches the game from Game Center and requests to play with a friend
-(void)player:(GKPlayer *)player didRequestMatchWithRecipients:(NSArray *)recipientPlayers
//Never seen this fire. Possibly fired when the user launches the game from Game Center. Unclear how this varies from didRequestMatchWithRecipients
-(void)player:(GKPlayer *)player didRequestMatchWithOtherPlayers:(NSArray *)playersToInvite
#pragma mark - Ending turn based matches (GKLocalPlayerListener)
//I've never seen this fire
-(void)player:(GKPlayer *)player matchEnded:(GKTurnBasedMatch *)match
//I've never seen this fire
-(void)player:(GKPlayer *)player wantsToQuitMatch:(nonnull GKTurnBasedMatch *)match
#pragma mark - challenges (GKLocalPlayerListener)
//untested, I don't use challenges
-(void)player:(GKPlayer *)player issuedChallengeWasCompleted:(GKChallenge *)challenge byFriend:(GKPlayer *)friendPlayer
//untested, I don't use challenges
-(void)player:(GKPlayer *)player didCompleteChallenge:(GKChallenge *)challenge issuedByFriend:(GKPlayer *)friendPlayer
//untested, I don't use challenges
-(void)player:(GKPlayer *)player didReceiveChallenge:(GKChallenge *)challenge
//untested, I don't use challenges
-(void)player:(GKPlayer *)player wantsToPlayChallenge:(GKChallenge *)challenge
#pragma mark - exchanges (GKLocalPlayerListener)
//seems to work as expected
-(void)player:(GKPlayer *)player receivedExchangeCancellation:(GKTurnBasedExchange *)exchange forMatch:(GKTurnBasedMatch *)match
//this fires for the Current Player AND the Exchange Initiator AFTER all replies/timeouts are complete.
-(void)player:(GKPlayer *)player receivedExchangeReplies:(NSArray *)replies forCompletedExchange:(GKTurnBasedExchange *)exchange forMatch:(GKTurnBasedMatch *)match
//seems to work as expected
-(void)player:(GKPlayer *)player receivedExchangeRequest:(GKTurnBasedExchange *)exchange forMatch:(GKTurnBasedMatch *)match
#pragma mark - event handler (GKLocalPlayerListener)
-(void)player:(GKPlayer *)player receivedTurnEventForMatch:(GKTurnBasedMatch *)match didBecomeActive:(BOOL)didBecomeActive
/*
Apple says this fires when:
1. When it becomes the active player's turn, including the inviting player creating a new match (CHECK)
2. When the time out is about to fire (FAIL. It fires AFTER the timeout expires, which may just be item #4 happening)
3. Player accepts an invite from another player (FAIL. Never happens. Instead it fires when an INVITED player starts playing a session FROM this player.)
4. Turn was passed to another player. (CHECK)
5. player receives a reminder (CHECK, confirmed by μ4ρκ05)
It Also fires when:
6. A remote user quits (CHECK)
7. A remote user declines (unconfirmed)
8. An automatch player joins the game (CHECK)
9. An invited player starts playing (CHECK)
10. A remote user saves the game (CHECK)
*/
编辑:根据 μ4ρκ05 的反馈更新了“提醒”通知的状态。