Reputation: 1908
I am developing an app that reports a score to Game Center using the code below (as suggested by Apple). My problem is that even when my iPhone is in Airplane mode, the app does not trigger any score reporting error. It just goes to the "Submission ok" section of the code. Any idea why? Thank you!
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease];
scoreReporter.value = score;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil)
{
// handle the reporting error
NSLog(@"Error Descr %@",error.localizedDescription);
NSLog(@"Error Code %@",error.code);
NSLog(@"Error Domain %@",error.domain);
}
else {
NSLog(@"Submission ok");
}
}];
Upvotes: 0
Views: 805
Reputation: 719
Starting with iOS 5.0, any network errors arising out of reportScoreWithCompletionHandler
are handled internally by GameKit. This means that developers no longer have to worry about resubmitting scores pending due to network failures. If you're building with iOS 5.0 and later, the completion handler of reportScoreWithCompletionHandler
will not receive any network-related errors.
Upvotes: 1
Reputation: 14304
I would suggest using Apple's reachability flags to detect an active connection yourself. If a connection isn't available, store your Game Center requests for future submission and submit them when network becomes available again. More on reachability can be found here
Upvotes: 0