游戏中心分数报告问题

发布于 2024-12-11 16:31:00 字数 670 浏览 0 评论 0原文

我正在开发一个应用程序,使用下面的代码(按照苹果的建议)向游戏中心报告分数。 我的问题是,即使我的 iPhone 处于飞行模式,该应用程序也不会触发任何分数报告错误。它只是转到代码的“提交确定”部分。 知道为什么吗? 谢谢你!

    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");
        }
    }];

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");
        }
    }];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谁对谁错谁最难过 2024-12-18 16:31:00

从 iOS 5.0 开始,由 reportScoreWithCompletionHandler 引起的任何网络错误均由 GameKit 在内部处理。这意味着开发者不必再担心因网络故障而重新提交待处理的分数。如果您使用 iOS 5.0 及更高版本进行构建,则 reportScoreWithCompletionHandler 的完成处理程序将不会收到任何与网络相关的错误。

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.

柠栀 2024-12-18 16:31:00

我建议您自己使用 Apple 的可达性标志来检测活动连接。如果连接不可用,请存储您的 Game Center 请求以供将来提交,并在网络再次可用时提交。有关可达性的更多信息,请访问此处

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文