iphone - 我如何获得 GameKit 回合制比赛的通知?

标签 iphone objective-c cocoa-touch ipad gamekit

我正在使用新的回合制 iOS5 API 开发回合制 iOS 游戏。

您需要为此实现的委托(delegate)协议(protocol)之一是 GKTurnBasedEventHandlerDelegate。要实现的方法之一是 handleTurnEventForMatch。这是来自有关此方法的 Apple 文档:

handleTurnEventForMatch

Sent to the delegate when it is the local player’s turn to act in a turn-based match.

- (void)handleTurnEventForMatch:(GKTurnBasedMatch *)match

参数

match - A match object containing the current state of the match.

讨论

When your delegate receives this message, the player has accepted a push notification for a match already in progress. Your game should end whatever task it was performing and switch to the match information provided by the match object.

我的大部分游戏都运行正常。我收到通过上述方法收到的移动通知。 我还看到应用程序图标上的徽章已成功更新。

但是,当回合事件进入时,我没有收到任何其他系统通知;通知中心等什么都没有显示。我需要在 GameKit 之外做些什么来启用它吗?获取handleTurnEventForMatch时需要手动发送本地通知吗?文档似乎暗示不是,因为它在上面说“当您的代表收到此消息时,玩家已经接受了正在进行的比赛的推送通知。”

所以这似乎暗示着玩家点击了一个推送通知来调用这个方法(当然他们从来没有出现过,所以我没有!)

我需要做什么才能在我的应用程序中为基于回合的事件启用推送通知?当我收到上述方法时,我是否需要实际发送本地通知(考虑到上述文档的措辞,这似乎与意图相矛盾)。

最佳答案

我刚刚完成了这个过程,在将头撞到 table 上大约一周后,我发现了这些重要的事情:

(1) 模拟器不会收到这些转弯通知。一旦我完成这项工作,它就可以在两个设备之间正常工作。与设备对战的模拟器将发送事件,但不会接收事件。因此,如果您尝试使用一台设备和模拟器来测试它,祝您好运。使用两个设备。

(2) 确保在 iTunes connect 中打开了“Game Center Enabled for this Version”,并确保应用程序中的 CFBundleVersion 与该版本匹配。我一这样做,一切就开始工作了。

我假设你已经完成了: [GKTurnBasedEventHandler sharedTurnBasedEventHandler].delegate = YOUR_DELEGATE_CLASS;

关于iphone - 我如何获得 GameKit 回合制比赛的通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7935336/

相关文章:

iphone - 如何在 UITableView 中显示 NSSet?

objective-c - objective-C 头文件中的 weak in swift 消失了

objective-c - 如何使用 Scrollview(或最佳实践)垂直和水平地进行 Card Deck 样式页面转换

iphone - 以编程方式设置 UITabBar 标题

iOS MapKit CompleterDidUpdateResults 未调用

ios7 调节 iPodMusicPlayer 音量

android - WebGL 硬件在移动平台上加速了吗?

ios - 在自定义 UIView 中动画化 UIBezierPath 不起作用

iphone - 错误 : linker command failed with exit code 1 (use -v to see invocation)

ios - 如何添加导航栏 "Plus"按钮,并在代码中使用