Is there a way to update matchData in a GKTurnBasedMatch without sending out “Your Turn” push notifications?

落爺英雄遲暮 提交于 2020-01-11 06:51:14

问题


If my understanding is correct, the only way to update the matchData property of a GKTurnBasedMatch mid-turn is [_currentMatch endTurnWithNextParticipant:_currentParticipant matchData:matchData completionHandler:nil].

This works well if the Game Center player only has the game installed on one device because the notification is delivered to the device as a message to the app. Thus, the notification can be hidden while the user is currently playing his turn. However, if the user has the game installed on multiple devices, the other devices will get a "Your Turn" push notification. This is confusing to the user, especially I update the matchData multiple times.

By the way, I understand that I may not be using the endTurnWithNextParticipant:matchData:completionHandler: function as it was intended (because I am not, in fact, ending the match... but merely updating the matchData). However, there seems to be no alternative to update the match's state mid-turn.


回答1:


Mid-turn saving has been added in iOS 6 with:

-[GKTurnBasedMatch saveCurrentTurnWithMatchData:completionHandler:]

Source: GKTurnBasedMatch Class Reference




回答2:


Interestingly, to address your original question, it appears that saveCurrentTurnWithMatchData still sends out push notifications to the other players, even though the current player's turn hasn't ended!

In my opinion, this seems like a GameKit design flaw- it seems inherently misleading to have a badge show up on an opponent's app icon when it isn't yet their turn. What a bummer to open it and see that it's just a false alarm over and over!

If anyone has figured out a way to suppress these push notifications when calling saveCurrentTurnWithMatchData, I would love to hear how you did it.

UPDATE: I started a new thread to address this issue.




回答3:


There shouldn't really be a reason to update the match data during the turn. None of the other players can react until their turn, so the data only needs to be passed as play transitions from one player to another.



来源:https://stackoverflow.com/questions/9760209/is-there-a-way-to-update-matchdata-in-a-gkturnbasedmatch-without-sending-out-yo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!