ios - Leaderboard Integation not working -
i creating game ios 7 , trying implement game center leaderboards. got app open leaderboard when click button, says "no items". not sure right if problem submitting scores or retrieving leaderboards. appears problem submitting score because says app name on top of leaderboard, can't find error. code submit score:
-(void)reportscore:(nsinteger ) highscore { if ([gklocalplayer localplayer].isauthenticated) { gkscore *scorereporter = [[gkscore alloc] initwithleaderboardidentifier:@"flapjacks1" forplayer:[gklocalplayer localplayer].playerid]; scorereporter.value = highscore; nslog(@"score reporter value: %@", scorereporter); [gkscore reportscores:@[scorereporter] withcompletionhandler:^(nserror *error) { if (error != nil) { nslog(@"error"); // handle reporting error } }]; }
}
this method retrieving leaderboard:
-(void)displayleaderboard { //nsstring *_leaderboardidentifier = @"flapjacks1"; [[gklocalplayer localplayer] loaddefaultleaderboardidentifierwithcompletionhandler:^(nsstring *leaderboardidentifier, nserror *error) { if (error != nil) { nslog(@"%@", [error localizeddescription]); } else{ //_leaderboardidentifier = leaderboardidentifier; gkgamecenterviewcontroller *gamecentercontroller = [[gkgamecenterviewcontroller alloc] init]; if (gamecentercontroller != nil) { gamecentercontroller.gamecenterdelegate = self; gamecentercontroller.viewstate = gkgamecenterviewcontrollerstateleaderboards; //gamecentercontroller.leaderboardtimescope = gkleaderboardtimescopetoday; gamecentercontroller.leaderboardidentifier = @"flapjacks1"; [self presentviewcontroller: gamecentercontroller animated: yes completion:nil]; } } }]; }
Comments
Post a Comment