Authenticating

Game Center is an authenticated service, which means that you cannot do anything but authenticate when you are not logged in. With this in mind you must first authenticate before being able to proceed with any of the leaderboard relevant code. Authenticating with Game Center is handled mostly by iOS for you. The following code will present a UIAlert allowing the user to log in to Game Center or create a new Game Center account.

Note

Do not forget to include the GameKit.framework and import GameKit/GameKit.h whenever you are working with Game Center.

- (void) authenticateLocalUser{    if([GKLocalPlayer localPlayer].authenticated == NO)    {        [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.