2

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 ...

Sezertt
  • 105
  • 9
  • 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 Sep 05 '13 at 23:28

1 Answers1

-1

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];
    }];
}
RobertL
  • 14,214
  • 11
  • 38
  • 44
  • I am using almost the same code that you have been using. I am sorry, I didnt mention that posted many scores on my leaderboards successfully but it works fine only when I have network. And that should be "and" not "or" I made a mistake there :) – Sezertt Jan 18 '13 at 21:24
  • Where I wrote (wifi or cellular). But I am not asking any of these, I really need to know only this resend thing that Game Center handles for us when no network is available... – Sezertt Jan 18 '13 at 21:30
  • By the way when I try to report a score when there is no network connection available it gives no error, it says that it successfully reported the score... – Sezertt Jan 18 '13 at 22:24
  • Yes it does that. I guess it means that the report was successfully queued for transmission when the network is available. – RobertL Jan 18 '13 at 23:20
  • But I have been waiting for 2 days now and there is no updated score... I logged in submitted another score to another leaderboard successfully but no offline scores submitted yet ... – Sezertt Jan 18 '13 at 23:24
  • So far as I can tell the "resend" or "try again" function works as you expect. Maybe there's some situation where it doesn't work but I haven't seen it yet. BTW the fact that the local player is authenticated does not prove the network is available. – RobertL Jan 18 '13 at 23:33
  • I'll try my app with airplane mode on then turn it off after I submit a score and post another comment about what happened. – RobertL Jan 18 '13 at 23:36
  • I see that my score is not reported until the app is launched again when airplane mode is off, but then it does get reported properly. My app was not running in the background during that test. If it was running in the background when airplane mode is turned off it might report the score then. It's not too convenient for me to test that possibility. This web site might block further comments because it thinks discussion is bad. – RobertL Jan 18 '13 at 23:51
  • As i said earlier when i try to send a score in airplane mode it doesnt return any errors and this situation also blocks me for resubmitting it later manually because i cant know the unreported scores. I didnt understand what you mean by ""resend" or "try again" function works as you expect". It never tries to resend the score when the network is available. I hope you will find an answer for me. BTW thank you for spending your time for my problem... – Sezertt Jan 18 '13 at 23:52
  • Are you using GameCenter Sandbox or is your app live ? I am using the same code that you wrote in your answer but mine never tries to send it when network is available so i thought maybe it is because of sandbox... – Sezertt Jan 19 '13 at 00:02
  • I searched this deeply on the internet and couldn't solve the problem... Also I saw some others suffering from the same situation [link] (http://simx.me/technonova/software_development/offline_game_center_reporting.html) so I checked for the connection on my app and if there isn't any, i stored the score's to submit when connection is available... I also posted a bug report to Apple. I hope it will be fixed for others... – Sezertt Jan 21 '13 at 16:52