How to know when an invitee declines a turn based match invite via the push notification action button.

I am developing a turn based game using GameKit. The happy path (pretty much as always) is fine; invite, accept, play, have winners/losers and match ends. Yay! But I am working on making sure I handle situations where invited friends decline to participate.

I've been through the docs, and don't see how the GKTurnBasedMatch is updated to reflect the tap of the decline button in the Game Center Invite notification. When I reload the match from Game Center on the host device the status for the invitee who declined is still .invited.

I also tested by setting all players that are not the host in the nextParticipants of the endTurn(...) to start the invites and the next invitee was not given a push notification to accept or decline the invite.

I feel like there should be a way to determine when an invitee has declined an invite (via participant in the match.participants via status OR a delegation method somewhere that is called when the Decline or Accept buttons on that notification are tapped.)

I'm missing something, please help me find it!

Thank you!

Answered by livelydev in 817686022

Further investigation shows that status of invited participants is .matching until they accept in the push notification panel or take action leading to their turn being ended by calling endTurn(...). Tapping decline leads to a status for that participant of .invited. If a player misses the push or otherwise ignores it, they remain .matching.

So to answer my question: Participant States based on Actions WRT the Invite Message Game Center Push Notification:

  • .matching is starting status
  • .matching remains after push is seen and ignored or otherwise missed.
  • .invited if the user taps "Decline"
  • .active if the user taps "Accept", even if they do not take any action in the app OR the app does something on the player's behalf.

Further investigation has turned up some interesting things:

  1. The docs say a match will be cancelled if declined. So this may not be desirable. This status is CLEARLY not being set when a user long touches their push notification and then taps Decline.
  2. Setting timeout works as expected on GKTurnBasedMatch.endTurn(...) whether the players ignore the invite OR tap to Decline in the notification.

My take away is to assume we can only handle positive actions (acceptance of invite by completing action that causes my app to endTurn for that player) and timeouts with the host player being the last participant in the nextParticipants array so they can do something.

My guess, to answer my own question, is that there is no way to know this has happened and that either this is completely a no-op from a Game Center or Turn Based Match perspective.

I think this is not GREAT per se, but is fine for sure. I also think my expectation that I can plan out every possible situation is too expansive and should be set to let the host know at some point that all they can do is delete the match, wait it out, or ignore it.

I think an article in the docs to cover the various paths OTHER than the expected happy path would be great. Overall, the docs do seem to be pretty solid, but sometimes it is hard to find things. Maybe this is just me? 🤦‍♀️

I am leaving this open in case someone can definitively shed light on if there is a way to find out if this decline via notification happens OR what happens with Game Center, if anything.

Accepted Answer

Further investigation shows that status of invited participants is .matching until they accept in the push notification panel or take action leading to their turn being ended by calling endTurn(...). Tapping decline leads to a status for that participant of .invited. If a player misses the push or otherwise ignores it, they remain .matching.

So to answer my question: Participant States based on Actions WRT the Invite Message Game Center Push Notification:

  • .matching is starting status
  • .matching remains after push is seen and ignored or otherwise missed.
  • .invited if the user taps "Decline"
  • .active if the user taps "Accept", even if they do not take any action in the app OR the app does something on the player's behalf.
How to know when an invitee declines a turn based match invite via the push notification action button.
 
 
Q