GameKit I: Setting up your App in iTunesConnect

For the last two weeks I’ve been thinking on what can your application implement so it can improve as a product.

First think that came to my mind, appart from having a funny game by itself, is adding some challenge to the players.

iCheese is the first app I’ve made so far and although I consider it a good idea that can make it into the appstore without feeling bad or shy if somebody spends 1$ on it (I do play it in fact, mostly against my g/f tho), it needs an addictive touch.

On the other side, I was thinking on what would be the best option in order to quantify the player score after a match (this is the problem you find when you didn’t plan every aspect of the app, which I consider a must in the design phase now), the best idea IMO is to store the amount of time it took to beat the oponent. The less time you spend on a match the higher you should be ranked in an hipotetic highscores chart.

Now I know I want to add a highscore system to my game and it consist on the time  the matches last.

Since I’m not like developing a webserver to store it, best option is GameCenter. GameCenter provides almost everything you might need to develope the “social” aspects of your game.

This first post is an overview of the process I’m following in order to set up a sandbox environment to test GC (GameCenter)  functionality. The things you’ll need:

1.- Appropiate AppID: Apple let’s you request the star operand (*) in the Bundle application name, but those AppID’s will disable all the GameKit features for your app. make sure you introduce a concrete app name like com.yourcompany.appname because com.yourcompany.* and then your appname in “App Id Name” won’t work.

Apple allows you to use the star operand so you can hold a suite of apps which are related one another under the same bundleId.

Use a concrete one.

2.- Config you application on iTunes Connect using the “add App” button and once you have filled up every field in the request and your app draft is setted up, edit the GameCenter configuration and enable your highscores.

In GameCenter, highscores require that you set up the categories you’ll use. In my case, categories are “easy”, “medium” and “hard” because I don’t want to mix the scores from different difficulty levels. You can localize your highscores charts by using the correct formatter for each location and field and also a score suffix such as “minutes” in my case.

At this point this is handy and important: You don’t need to upload any code or binary yet.

3.- Add the related GameKit code to your app. I strongly recommend using the Game Kit Programming Guide provided by Apple to start with. Decide if GameCenter is required or optional in your application (I want users of older devices to be able to play and have a local highscores system so I went for optional) The document has a section called “Optionally Using Game Center In Your Application” where you will find the next piece of code:

– (BOOL) isGameCenterAvailable() 

// Check for presence of GKLocalPlayer API.
Class gcClass = (NSClassFromString(@”GKLocalPlayer”));
// The device must be running running iOS 4.1 or later.
NSString *reqSysVer = @”4.1″;
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
BOOL osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);
return (gcClass && osVersionSupported);

It will let you detect if the device you’re running the app on supports GameCenter and take the necessary actions ingame. My actions for now are simple: Enable a BOOL flag called isGameCenterEnabled in my code that I’ll be reading in order to chose if I’m using the local highscores chart or GameCenter’s one. This decision will also be affected by another check you’ll find in the section “Authenticating the Local Player”:

– (void) authenticateLocalPlayer
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {
if (error == nil)
// Insert code here to handle a successful authentication.
// Your application can process the error parameter to report the error to the player.

If the first check returns “true” you can proceed with the second check and authenticate the local player. When you run this code, if you have an user logged in your device you will use that user, if you don’t, the app will prompt you to log in or create a new account.

By now, this code lies on my appDelegate since I consider we are receiving some notifications that the delegate should handle. UIKit modal views require that you place them in a ViewController. My game design was based on the work of Michael Daley from, and the tutorials don’t use a ViewController on top of the application. I’ll place the code in some of the UIKit views I add as sub-views in the main openGL ES view like the settings, local highscores, etc…

4.- A test account. This is the easiest step, log off your standard-gamer-account and start debugging you game on your device or simulator (you can also use the simulator for highscores and achievements but won’t work for multiplayer gaming) Once it prompts you to log in, just create a new account (using a diff account for testing than your daily one as game is recommended by Apple, I usually follow their advices).

If everything went right, at this point, you’ll have a GameCenter enabled app that authenticates your player and shows the cute “Wellcome to game center, playerName” message on top of your view for some seconds.

For the next entry I’ll talk about handling some events that we must code such as the player sending your app to background and disconnecting from GameCenter and then oppening your app again, etc… In this case you must make sure no GameCenter functionality remains enabled in your app, in my case: Set the isGameCenterEnabled flag to “false” 😛

“Thanks for watching!”


Acerca de lapsusmental

Computer engineer working as a Banking Applications Developer in a multinacional firm. Actually, this blog is intended to cover my latest, and more exciting, hobby I'm spending my spare time on: iPhone Game Development. Everything I managed to learn on my own or visiting the many sites where more skilled and experienced people share they knowloedge has room in this site.
Esta entrada fue publicada en Tutorials y etiquetada , , , , , , , . Guarda el enlace permanente.


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s