2
votes

I'm creating a game like application which supports Game Center. And I have a problem with reporting score to leaderboard when the player is authenticated to GC correctly but the network (wifi and cellular) is not available in the time when I want to report my score.

My app is for iOS 5.0 and greater and according to the documentation, it should resubmit the scores when network becomes available. Let me explain what i tried :

  • I opened my app and authenticate my GC account, turned the wifi off, reported score then opened wifi and waited 30 minutes. After that I checked leaderboard but there isnt any updated score on my leaderboard. (Maybe I am impatient and that is because of the undefined time / interval which apple decides to resubmit scores ?)

  • I opened my app and authentacate my GC account, terminated the app, turned the wifi off, opened my app again, it automatically authenticate's my GC account, I reported score then opened wifi and still no updated score on my leaderboards. (Maybe I am impatient and that is because of the undefined time / interval which apple decides to resubmit scores ?)

If this resubmit takes more then 30 minutes, I think it is so useless? Is there a way to overcome this? I mean if I save and send the scores later this would be bad too because GC will resubmit them later too? (It wont be so bad but still it would be unnecessary)

Is there any documentation about this resubmitting time ? I couldn't find any... I mean when will it resubmit? Do i need to keep my app and my wifi open until it resubmits?

Thank you for your answers ...

1
I'm struggling with the same thing. Did you ever find a resolution or any further insight into this problem? My suspicion - or rather, my hope - is that the automatic store-and-forward syncing that is supposed to be available in ios 6.0 and later actually doesn't work for apps that are not live and using sandbox test accounts. My problem with doing a manual sync when I detect that the network connection has been re-established is that the score will be submitted with a current timestamp and not the historical timestamp of the score.jay492355

1 Answers

-1
votes

It doesn't matter whether wifi is on or off if you also have a cellular connection. The GC code will use whichever network access is available. If neither is available when you call 'reportScoreWithCompletionHandler:^(NSError *error)' it will report the score the next time the network becomes available.

You didn't say whether your code has ever worked. A common error is that the leaderboard identifier in your code doesn't exactly match the leaderboard ID in iTunesConnect. If they don't match the score will never be successfully reported but it won't tell you what the problem is.

Also note that the score should be a 64-bit value. Maybe you are reporting a 32-bit value.

Also be sure you aren't submitting the score before the local player is authenticated.

Are you checking the error code? If the 'error' you get back from 'reportScoreWithCompletionHandler:^(NSError *error)' is not NULL then something is wrong with your code. Its value may not be helpful (when it isn't NULL) but at least you know that something didn't work.

In my experience, in sandbox mode, the leaderboards usually update fairly quickly (less than a minute) but not instantly. But some days something is wrong with the server and the update takes hours or doesn't work at all. I've read that the production GC server is more reliable and updates faster than the sandbox server.

For what it may be worth here's the code I've been using to report scores. It seems to work:

-(void) submitScore:(int64_t)score category:(NSString *)leaderboardIdentifier {
    if (!!! [GKLocalPlayer localPlayer].authenticated ) {
        CCLOG(@"GKLocalPlayer is not authenticated");
        return;
    }

    GKScore *gkScore = [[[GKScore alloc] initWithCategory:leaderboardIdentifier] autorelease];
    gkScore.value = score;
    [gkScore reportScoreWithCompletionHandler:^(NSError *error) {
        [self setLastError:error];
    }];
}