Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up third-party server to interact with Game Center

I'm thinking of adding a feature to my iOS game to allow players to create their own game levels, share them with other players, rate them, etc. There'd be a public repository of user-created levels, sortable by creation date, rating, difficulty, or other criteria.

This kind of functionality would necessitate a third-party server. I was thinking I'd create a RESTful API using Sinatra and run it on Heroku. My question is: what would be the best way to authenticate requests to this API? I would prefer not to require players to create a username and password. I'd like to just use Game Center's ID system.

Any suggestions? I've never done any server-side stuff before so any help is appreciated!

Clarification

Yes, I'm aware that Apple doesn't provide its own system. But it does give developers access to unique Game Center identifiers (developer.apple.com/library/mac/#documentation/…) and I was hoping I could use that somehow to roll my own authentication system without requiring users to sign on via Facebook/Twitter/etc. If that's possible.

like image 251
Andrew Clark Avatar asked Apr 02 '13 03:04

Andrew Clark


People also ask

How do you play with people on Game Center?

Send your invitation, then wait for the others to accept. When everyone's ready, start the game. If a friend isn't available or doesn't respond, you can tap Auto-Match to have Game Center find another player for you, or tap Invite Friend to invite someone else.

Can you connect Game Center to PC?

Features of Games Center on PC From now on, get a full-screen experience of your app with keyboard and mouse. MEmu offers you all the surprising features that you expected: quick install and easy setup, intuitive controls, no more limitations of battery, mobile data, and disturbing calls.

Can Game Center play with Google Play?

You cannot. Game Center is an iOS feature exclusively. It has nothing to do with Google. google Play, PC's nor Android.


1 Answers

Looks like as of iOS 7, this is possible with Game Center using:

[localPlayer generateIdentityVerificationSignatureWithCompletionHandler]

Once you have verified the identity of the player using the generateIdentity call,

  • Associate the player id with a user on your server's db
  • Use whatever access token / authentication pattern your REST framework provides for subsequent calls

https://developer.apple.com/library/ios/documentation/GameKit/Reference/GKLocalPlayer_Ref/Reference/Reference.html

Also for reference, here is the dictionary that we end up sending off to our server based on the response from generateIdentityVerificationSignatureWithCompletionHandler

NSDictionary *paramsDict = @{
    @"publicKeyUrl":[publicKeyUrl absoluteString],
    @"timestamp":[NSString stringWithFormat:@"%llu", timestamp],
    @"signature":[signature base64EncodedStringWithOptions:0],
    @"salt":[salt base64EncodedStringWithOptions:0],
    @"playerID":localPlayer.playerID,
    @"bundleID":[[NSBundle mainBundle] bundleIdentifier]
};
like image 94
andyzinsser Avatar answered Oct 27 '22 00:10

andyzinsser