问题
Recently google added the concept of a Gamer ID to Google Play Games services which allows a player to setup a gaming identity distinct from their google+ identity. http://officialandroid.blogspot.co.uk/2016/02/embrace-your-inner-gaming-hero-with.html
My use case is that I have an online multiplayer game which uses my own matchmaking server. I don't use Google Play Game's matchmaking because I require skill-based matchmaking capabilities that are not currently available using GPGS.
I'd like to be able to display the player's Google Play Games identity (just the name) if they happen to have signed in. However, I had previously elected not to for privacy reasons as I know that in Quick Matches with GPGS, google elects to conceal your opponent's identities, and I felt I should follow their lead.
Now, I think that part of the reason that gamer IDs have been added is to avoid the need for such caution over privacy. So I have the following questions:
- Is there any way to programmatically get the Google Play Game Gamer ID of the local player?
- Is there a way to be sure that what I have got is a Gamer ID, and not the old-style google+ identity which carries extra privacy issues?
- Am I right in assuming that privacy over the new Gamer IDs is more relaxed and that google and my users will not be concerned about having gamer IDs shared when playing against random opponents on the internet?
回答1:
You can get some more information from http://android-developers.blogspot.com/2016/01/play-games-permissions-are-changing-in.html
Quick answers to your questions:
You can programmatically get the local player's ID, name and avatar as usual using Games.getCurrentPlayerId() or Games.getCurrentPlayer() then using Player.getDisplayName().
You can verify the player's identity on the server side using
www.googleapis.com/games/v1/applications/<app_id>/verify/
with a token obtained as described in the blog post. The updated permissions are rolling out now, so I'd expect it to be everywhere very soon.Yes, the new gamer identity is independent of Google+ for exactly this reason. So you can safely use the gamer identity without risking the privacy of the player.
来源:https://stackoverflow.com/questions/36177641/how-to-access-google-play-games-gamer-id