game center report score not working - iphone

gameCenterManager
[gameCenterManager reportScore:score_value forCategory:#"123"];
not working?? whenever I send a score through the above line , when I run this applciation and open gdb then Missed Method is saying in the callDeletgete
how can I solve it

my report score codees are like this:
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:#"123"] autorelease];
scoreReporter.value = 123456;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil)
{
// handle the reporting error
}
}];

Related

Wait until GameCenter score download id complete

I would like to download score from GameCenter, but I don't know how to wait, when score is downloaded. When I run this code, it returns null. I think, that method have to wait when [leaderboardRequest loadScoresWithCompletionHandler: ... will have score downloaded.
- (NSString*) getScore: (NSString*) leaderboardID
{
__block NSString *score = nil;
GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
if (leaderboardRequest != nil)
{
leaderboardRequest.identifier = leaderboardID;
[leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
if (error != nil)
{
NSLog(#"%#", [error localizedDescription]);
}
if (scores != nil)
{
int64_t scoreInt = leaderboardRequest.localPlayerScore.value;
score = [NSString stringWithFormat:#"%lld", scoreInt];
}
}];
}
return score;
}
The code from the completion handler will be called when the operation is complete (on another thread).
You have several options there, you can store the score somewhere and post a notification to notify the main thread that the operation is completed.

Gamer Center leaderboard shows no scores, and each user only has access to their own score

I'm trying to make a leaderboard in my game with Game Center. I post the high score like so:
GKScore *myScoreValue = [[[GKScore alloc] initWithCategory:#"grp.high_scores"] autorelease];
myScoreValue.value = self.game.scoreMeter.score;
NSLog(#"Attemping to submit score: %#", myScoreValue);
[myScoreValue reportScoreWithCompletionHandler:^(NSError *error){
if(error != nil){
NSLog(#"Score Submission Failed");
} else {
NSLog(#"Score Submitted");
id appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate displayLeaderBoard:nil];
}
}];
I see "Score Submitted" as expecting, and it brings up the Game Center leaderboard view, but it just reads "No Scores"
I know other people have said you need at least two accounts, but I've tried with three already.
For each account, the game shows up for them in the Game Center App, and when I query for the top ten scores:
- (void) retrieveTopTenScores
{
GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
if (leaderboardRequest != nil)
{
leaderboardRequest.playerScope = GKLeaderboardPlayerScopeGlobal;
leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime;
leaderboardRequest.range = NSMakeRange(1,10);
[leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
if (error != nil)
{
NSLog(#"Error grabbing top ten: %#", error);
}
if (scores != nil)
{
NSLog(#"Top ten scores: %#", scores);
}
}];
}
}
each user only sees their own score.
So why is the leaderboard empty, and why is each user only seeing their own score?
Sandbox can be messy sometimes, but let me ask you this. Is your self.game.scoreMeter.score an int?
If so, try doing this:
myScoreValue.value = [[NSNumber numberWithInt:self.game.scoreMeter.score] longLongValue];
for setting the value of the GKScore object. Let me know if it changes anything.
Well, it turns out you need to be signed in to game center with a developer sandbox account for it to work correctly

Showing Game Center high scores in UILabels

I'm making a turn based iPhone game with a maximum of 2 players, in my game You can get a score which will be put in a Game center leaderboard. The next time you start the game up your highest score will be retrieved and you can make it even higher because the app counts on from that previous highscore. I found some code to get the authenticated players score But I also wanna show the score of the opponent you are playing and I was wondering how?
This is the code I found for the authenticated player (yourself)
if([GKLocalPlayer localPlayer].authenticated) {
NSArray *arr = [[NSArray alloc] initWithObjects:[GKLocalPlayer localPlayer].playerID, nil];
GKLeaderboard *board = [[GKLeaderboard alloc] initWithPlayerIDs:arr];
if(board != nil) {
board.timeScope = GKLeaderboardTimeScopeAllTime;
board.range = NSMakeRange(1, 1);
board.category = #"MY_LEADERBOARD";
[board loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
if (error != nil) {
// handle the error.
NSLog(#"Error retrieving score.", nil);
}
if (scores != nil) {
NSLog(#"My Score: %i", ((GKScore*)[scores objectAtIndex:0]).value);
}
}];
}
[board release];
[arr release];
}
is there a way to modify this so it will show what I want?
Also I have a problem showing NSLog(#"My Score: %i", ((GKScore*)[scores objectAtIndex:0]).value);
in a UILabel :S
Hope someone can help me out
NSLog(#"My Score: %lld", ((GKScore*)[scores objectAtIndex:0]).value);
the score values are 64bit integers, not int's
intValue
longValue
longLongValue <<==

High Score submission to Game Center not working

I'm doing an ios app based on maths..
I've done the code for uploading the high score to the Game Center..
but this doesn't work..
it's always showing 0 as the 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");
}
}];
}
I think you need to use an int64_t for your method! I use this method and it works perfectly fine :-)
-(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];
}];
}
Greetings
Anselm

game center score submission problem

i have integrate game center in my game ...and its working well but i have i new problem now :P
only one score is submit of user .. after that no score submit even its greater then posted score or less...
any idea what i have to exactly doo...
Regards
Haseeb
i use this to submit score......after being sure that the game center is available...
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:gameCenterCategory] autorelease];
int64_t score1 =socre;
scoreReporter.value = score1;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil) {
NSLog(#"Submit failed");
}
else {
NSLog(#"Score Submited");
}
}];
[pool release];