Book Image

Sparrow iOS Game Framework Beginner's Guide

By : Johannes Stein
Book Image

Sparrow iOS Game Framework Beginner's Guide

By: Johannes Stein

Overview of this book

Table of Contents (20 chapters)
Sparrow iOS Game Framework Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Afterword
Index

Time for action – integrating Game Center authentication


Use the following steps to integrate Game Center authentication:

  1. Open our Xcode project if it's not already open.

  2. Add GameKit.framework to the list of frameworks to be linked.

  3. Switch to AppDelegate.m.

  4. Import the GameKit header file using the following line of code:

    #import <GameKit/GameKit.h>
  5. Update the didFinishLaunchingWithOptions method to look like the following piece of code:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        CGRect screenBounds = [UIScreen mainScreen].bounds;
        _window = [[UIWindow alloc] initWithFrame:screenBounds];
        
        _viewController = [[SPViewController alloc] init];
        
        [Ubertesters initialize];
        
        [_viewController startWithRoot:[Game class] supportHighResolutions:YES doubleOnPad:YES];
        
        [GKLocalPlayer localPlayer].authenticateHandler = ^(UIViewController *viewController, NSError *error) {
            if ([GKLocalPlayer localPlayer...