Skip to content

Game Center deprecated methods in login() #30

Description

***WORKS ONLY ON iOS 6 DEVICES ***

Fix new login method:

BOOL isViewOnScreen; //yes when login is on screen

  • (void)login
    {
    GKLocalPlayer* localPlayer = [GKLocalPlayer localPlayer];
    if (localPlayer.isAuthenticated) {
    isViewOnScreen=NO;
    return;
    }

    NSLog(@"Game Center login ....");

    localPlayer.authenticateHandler =
    ^(UIViewController *viewController,
    NSError *error) {

    if (localPlayer.authenticated) {
       isAuthenticated = YES;
        [self retrieveScoresFromDevice];
        [self retrieveAchievementsFromDevice];
    } else if(viewController) {
        NSLog(@"Game Center shows login ....");
        isViewOnScreen=YES;
        [self presentViewController:viewController];
    } else {
         NSLog(@"Game Center error or canceled login ....");
        //User canceled Login view
       isAuthenticated = NO;
    isViewOnScreen=NO;
    }
    

    };
    }

pragma mark UIViewController stuff

-(UIViewController*) getRootViewController {
return [UIApplication
sharedApplication].keyWindow.rootViewController;
}

-(void)presentViewController:(UIViewController_)vc {
UIViewController_ rootVC = [self getRootViewController];
[rootVC presentViewController:vc animated:YES
completion:nil];
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions