I discovered the Game Center playerID has been deprecated in iOS 13.0 and we should use teamPlayerID or gamePlayerID instead. I started to play around with teamPlayerID value since Apple indicated in most cases we would be using the teamPlayerID value.
A) Once a match has been created, the teamPlayerID can be obtained for each player by looping through each player in the match (myMatch).
for player in myMatch.players
{
print("teamPlayerID = \(player.teamPlayerID)")
}
B) The teamPlayerID can also be obtained by calling the GKPlayer.loadPlayers(forIdentifiers:) function to obtain all player information. You can then loop through the player information to obtain the teamPlayerID for each player.
(Note: Creating the player map array using $0.teamPlayerID does not result in any data being returned)
let playerIDs = myMatch!.players.map { $0.playerID } as [String]
GKPlayer.loadPlayers(forIdentifiers: playerIDs) { (players, error) in ...
for player in players
{
print("teamPlayerID = \(player.teamPlayerID)")
}
Issues Found:
1) If Player1 performs (A) and (B) then they will notice the teamPlayerID values from (A) are not the same values as the ones from (B)
2) If Player1 performs (A) and Player2 performs (A), then both players will have different teamPlayerID associated with them both?
Meaning ...
- Player1 sees a different teamPlayerID value for Player2 than Player2 sees for themselves
- Player2 sees a different teamPlayerID value for Player1 than Player1 sees for themselves
As a result of these two issues, it does not seem the teamPlayerID value can be used to uniquely specify a particular "player" in Game Center. I confirmed one player cannot send data to another player since both players do not have the same teamPlayerID values that represent each player in the match. (Note: The same issue exist for the gamePlayerID value as well)
How can we use teamPlayerID to associate with a specific player in a match, when each player in the match has different teamPlayerID values for the players in the match?