After end of year distractions I've come back to working on this and have a couple of interesting new observations while testing a 3 player match (1 hostess and 2 friend invitees):
When the first invitee taps the push notification or taps to accept in the push notification actions, their status becomes .active. This means that this player has no way of NOT accepting if they interact at all with the push notification. Ugh.
When the second invitee taps the push notification, taps accept in the push notification actions, OR taps a button in my app to Accept the invitation that calls .acceptInvite() on the match's GKTurnBasedMatch instance, their status remains .matching.
This is frustrating because joining the match works differently for these two invitees. Both devices (iPad 6thG & iPhone SE 2ndG) are on iPadOS/iOS 17.5.1. Technically it is possible hardware matters here, but I feel this is unlikely.
The approach I was taking was for participant[0] (the hostess) to endTurn with all participants (1, 2, and 0 in that order) and a short time out (30s). During each participant's turn, they're presented with a button to accept the invite that only calls .acceptInvite() on the GKTurnBasedMatch instance. This should theoretically be actionable out of turn. The hostess is expected to be "in turn" before all the invites have been accepted and can see who has accepted and how many invites are outstanding. This felt like a good way to not require serial invitations and responses and to keep the hostess updated on the status of their new match.
I think the approach I'm going to have to take is go back to the original implementation where I ignored participant status and just invite each player and let them endTurn(_:) as they join. The only differences is I will check for .invited status and treat that as a declined invite AND allow the player to decline in the app which I can use to let the hostess know the match is over. The reason I rejected this is because a declined invite seemed difficult to identify. (As per the accepted answer, this is via participant.status == .invited) Also, I did not code for declines (tho that was what I was starting to work on when I posted this question.)
Topic:
Graphics & Games
SubTopic:
GameKit
Tags: