Game Center high scores not working

I am making a math based ios application. I made code to upload high marks to Game Center. but it does not work. it always shows 0 as a high score. This is my code ...

[[GKLocalPlayer localPlayer]authenticateWithCompletionHandler:^(NSError *error)
      {
            if (error ==nil) 
            {
                 CCLOG(@"Success");
            } else 
            {
                 CCLOG(@"Fail");
            }
       }];

.
.
.
.
.

-(void)showLeaderboard
{   
    if( ! gameCenterViewController_ )
        gameCenterViewController_ = [[GameCenterViewController alloc] init];

    [gameCenterViewController_ showLeaderboard];
}



-(void)submitMyScore1:(int)score1
{
    CCLOG(@"submitMyScore1--%d",score1);
    //This is the same category id you set in your itunes connect GameCenter LeaderBoard
    GKScore *myScoreValue = [[[GKScore alloc] initWithCategory:@"bigwizlist"] autorelease]; 
    myScoreValue.value = score1;

    [myScoreValue reportScoreWithCompletionHandler:^(NSError *error){
        if(error != nil)
        {
            CCLOG(@"Score Submission Failed");
        } else
        {
            CCLOG(@"Score Submitted");
        }

    }];
}
+3
source share
1 answer

I think you need to use int64_t for your method! I use this method and it works great :-)

-(void)submitScore:(int64_t)score category:(NSString*)category{

GKScore *gkScore = [[[GKScore alloc]initWithCategory:category]autorelease];
gkScore.value = score;

[gkScore reportScoreWithCompletionHandler:^(NSError* error)
 {
     [self setLastError:error];
     bool sucess = (error == nil);
     [delegate onScoresSubmitted:sucess];

 }];
}

Hi

Anselm

+3
source

All Articles