4

Is this impossible? I tried some test code that succeeds in making a match when the two players that I specify by ID are friends, but fails with this error when they aren't.

Using GKMatchmaker findmatchforrequest

Printing description of error:

Error Domain=GKErrorDomain Code=8 "The requested operation could not be completed because the player is invalid." UserInfo=0x1dd62f40 {GKServerStatusCode=5121, NSUnderlyingError=0x1dd62ca0 "The operation couldn’t be completed. Invitation between players who have not recently played: G:1752931323, G:1752935955", NSLocalizedDescription=The requested operation could not be completed because the player is invalid.}

Firoze Lafeer
  • 17,133
  • 4
  • 54
  • 48
Bontrey
  • 51
  • 2
  • possible duplicate of [Inviting a Game Center friend to a match programmatically](http://stackoverflow.com/questions/8451817/inviting-a-game-center-friend-to-a-match-programmatically) – Almo Jan 23 '14 at 18:11

2 Answers2

1

I would love to be able to do this too but I believe in the docs Apple specify that invites must be from friends only.

  • https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/GameKit_Guide/MatchmakingwithGameCenter/MatchmakingwithGameCenter.html "Almost always friends" It does not look like that is a restriction. – Almo Jan 23 '14 at 16:41
  • Thanks for the ref Almo, agreed it does imply that it should work. I last tried this with iOS 5 and it failed, perhaps with iOS 7 it would succeed (i.e. an invitation between two players who are not friends). I might be looking at this soon actually, if I do I'll update here too. – theLastNightTrain Jan 24 '14 at 19:36
1

It does work, yes - the restriction is that the players must have played recently. This could be the case in a few scenarios for players that are not friends:

  • They played a random match together
  • The players are playing or have previously played together over wifi or bluetooth
  • They used to be friends but removed each other from their friends list.
  • They played a 3+ multiplayer match where they were friends with one of the players, but not the other.
  • They are playing on 2 devices that previously played together, even if the GameCenter login for those devices has recently changed - hence they are not technically friends (Reset Network Settings removes this ability).

These cases are rare, hence the 'almost always friends' clause.

They way I'm handling this is to first attempt to do an invite, regardless of if they are friends. If this error results, I notify the user that they are not friends, and prompt them to send friend request using the friend request view controller.

Shaun Budhram
  • 3,690
  • 4
  • 30
  • 41