Gamecenter ios 9 GameCenter GKLocalPlayerListener方法未调用

这是关于GameCenter

由于“ GKLocalPlayerListener协议inheritance了GKChallengeListenerGKInviteEventListenerGKTurnBasedEventListener

为了处理多个事件,“和”不直接实现GKChallengeListenerGKInviteEventListenerGKTurnBasedEventListener ; 实现GKLocalPlayerListener

您可以使用GKLocalPlayerListener监听和处理多个事件“(这些来自Apple文档)。

可以预期,在GKLocalPlayer.localPlayer()经过身份validation后注册GKLocalPlayerListener后,当适当的事件发生时,将调用GKLocalPlayerListener中的所有方法。

但是,除了“播放器(播放器: GKPlayer ,receivedTurnEventForMatch匹配: GKTurnBasedMatch ,didBecomeActive:Bool)”之外,其他所有方法,包括“播放器(播放器: GKPlayer ,matchEnded匹配: GKTurnBasedMatch )”从未被调用过发生了一件事。

我们是否需要注册其他听众,或者我缺少什么?

关于检测到您被邀请参加回合制比赛:没有发送任何活动,但是当您从服务器查询比赛列表时,您只是突然出现一个新比赛(并且您的状态将被邀请)。 (收件人确实得到UIAlert提示他们已收到邀请)

关于各种API函数是否/何时触发,我花了很多很多小时试图在这些各种函数触发时进行解密。 我已经针对函数或文档打开了多个错误。 这是我目前的笔记; 这就是我在helper类中组织所有委托函数的方式,指出了它们应用于哪个侦听器以及指示它们触发的原因。

你可以看到有几个我从未破译过。 非常感谢此列表中的任何其他输入/说明。

 #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的反馈更新“提醒”通知的状态。

好的,你的各种方法的列表和解释让我思考。 首先。 收到匹配时没有收到通知的问题对我来说是最紧迫的问题之一,因为如果你没有收到通知就意味着你需要提取数据。 那么,你什么时候再次加载比赛? 每隔x秒或每次出现带有游戏列表的视图控制器? 两者都将发出不必要的网络呼叫,这将是令人讨厌的,并且由于可能需要重新加载游戏列表,而没有任何实际的改变,它可能看起来也不好。 所以起初我正在考虑使用交换,以便对手可以得到通知并重新加载游戏。 但是,阅读你记得的关于player receives a reminder (UNTESTED)post会player receives a reminder (UNTESTED)调用player receives a reminder (UNTESTED) 。 现在,我设法通过初始化新游戏,转弯,然后发送提醒来通知对手新游戏。

我已经更新了我的TurnBasedSkeleton项目。

我没有足够的声誉来评论Thunks的答案,但我可以提交我自己的,所以这就是我将如何获得这些信息。 问题的最大部分是没有关于如何使用此代码的示例,并且缺少文档。 因此,代码未触发不能certificate代码已被破坏,只是我们不知道如何使用它。

但基于Thunk正在制作的声明,我能够获得玩家:didModifySavedGame和player:hasConflictingSavedGames,他说他从未见过他们。

这些是GKSavedGameListener疯狂的方法。 我使用这个协议的问题是它没有一个委托来分配它,所以我可以选择我的程序中的任何类,并使其符合这个协议,然后期望方法触发,这似乎不太可能。 所以我需要某种代表来说明哪个类合适。

我发现通过设置localPlayer.registerListener(self),其中self是符合要求的类,我让它们触发。

因此请仔细检查任何未使用此设置触发的方法,并告诉我们它是否更好。

你没有遗漏任何东西。 Apple选择了

删除[这些]function[s]

我向Apple提交了一个错误提交进一步调查。 至少可以说,他们的反应令人不满意。

Apple bug报告