如何获取 GameKit 回合制比赛的通知?
我正在使用新的回合制 iOS5 API 开发一款回合制 iOS 游戏。
您需要为此实现的委托协议之一是 GKTurnBasedEventHandlerDelegate。要实现的方法之一是handleTurnEventForMatch。这是来自有关此方法的 Apple 文档:
handleTurnEventForMatch
轮到本地玩家执行任务时发送给代表 回合制比赛。
- (void)handleTurnEventForMatch:(GKTurnBasedMatch *)match
参数
match - 包含当前匹配状态的匹配对象。
讨论
当您的代理人收到此消息时,玩家已接受 推送正在进行的比赛的通知。你的游戏应该 结束正在执行的任何任务并切换到比赛 匹配对象提供的信息。
我的大部分游戏都可以运行。我收到通过上述方法收到的移动通知。 我还看到应用程序图标上的徽章已成功更新。
但是,当回合事件发生时,我没有收到任何其他系统通知;通知中心等中没有显示任何内容。我是否需要在 GameKit 之外执行某些操作才能启用此功能?当我获取handleTurnEventForMatch时,是否需要手动发送本地通知?该文档似乎暗示并非如此,因为它上面说“当您的代表收到此消息时,玩家已接受正在进行的比赛的推送通知。”
因此,这似乎意味着玩家已单击推送通知来调用此方法(但当然它们从未出现,所以我没有!)
我需要做什么才能在我的应用程序中启用基于回合的推送通知事件?当我收到上述方法时,我是否需要实际发送本地通知(考虑到上述文档的措辞,这似乎与意图相矛盾)。
I'm working on a turn based iOS game using the new turn-based iOS5 API.
One of the delegate protocols you need to implement for this is GKTurnBasedEventHandlerDelegate. One of the methods to implement is handleTurnEventForMatch. This is from the Apple docs on this method:
handleTurnEventForMatch
Sent to the delegate when it is the local player’s turn to act in a
turn-based match.
- (void)handleTurnEventForMatch:(GKTurnBasedMatch *)match
Parameters
match - A match object containing the current state of the match.
Discussion
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.
Most of my game is working. I'm getting notifications of moves received via the above method.
I'm also seeing badges on the app icons being updated successfully.
However, I am not getting any other system notifications when turn events come in; nothing shows up in the notification center, etc. Do I need to do something outside of GameKit to enable this? Do I need to manually send a local notification when I get handleTurnEventForMatch? The docs seem to imply not since it says above "When your delegate receives this message, the player has accepted a push notification for a match already in progress."
So this seems to imply that the player has clicked on a push notification to get this method called (but of course they never appear, so I have not!)
What do I need to do to enable push notifications in my app for turn-based events? Do I need to actually send a local notification when I receive the above method (this would seem to contradict the intent, given the verbiage of the above doc).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我刚刚完成了这个过程,经过一周左右的时间,我把头撞在桌子上,我发现了这些重要的事情:
(1)模拟器没有收到这些转弯通知。一旦我完成了这项工作,它就可以在两个设备之间正常工作。与设备进行游戏的模拟器将发送事件,但不会接收事件。因此,如果您尝试使用一台设备和模拟器来测试这一点,祝您好运。使用两台设备。
(2) 确保您在 iTunes connect 中打开了“Game Center Enabled for this Version”,并确保您应用中的 CFBundleVersion 与此版本匹配。一旦我这样做了,一切就开始工作了。
我假设你已经完成了:
[GKTurnBasedEventHandler共享TurnBasedEventHandler].delegate = YOUR_DELEGATE_CLASS;
I just finished fighting my way through this, and after a week or so of banging my head against the desk I discovered these important things:
(1) The simulator does not receive these turn notifications. Once I made this work, it works fine between two devices. A simulator playing versus a device will send events, but not receive them. So if you are trying to use one device and the simulator to test this, good luck. Use two devices.
(2) Make sure that you have "Game Center Enabled for this Version" turned on in iTunes connect, and make sure that the CFBundleVersion in your app matches this version. As soon as I did this, everything started working.
I assume you have already done:
[GKTurnBasedEventHandler sharedTurnBasedEventHandler].delegate = YOUR_DELEGATE_CLASS;
汤姆·舒尔茨说的是真的。但有一件事! :您可以使用设备获取通知,但不能使用模拟器获取通知。为此,请务必在构建和运行之前重置模拟器内容和设置。在模拟器上,您可以使用加载匹配方法来接收测试的内容。希望有帮助
Tom Schulz said true. But one thing! : you can get notifications with your device but not with simulator . To do this always reset your simulator content and settings before build and run . And on the simulator you can use load matches method to receive something for tests. Hope it helps
正如文档所述,当玩家接受推送通知(通常通过解锁手机或通过通知中心)时,就会收到该消息。发送推送通知由 Game Center 客户端决定,并由 GameKit 自动为您完成。您不需要实现 GKTurnBasedEventHandlerDelegate 即可让它们工作,只需响应接受它们的玩家(通过自动返回该比赛或其他方式)。
我想值得仔细检查您设备的通知设置,以查看您的应用程序是否启用了通知中心警报。
As the documentation says, that message is received when the player has accepted the push notification (typically by unlocking the phone or via notification center). Sending push notifications is decided in Game Center client-side, and automatically done for you by GameKit. You don't need to implement a GKTurnBasedEventHandlerDelegate in order for them to work, only to respond to the player accepting them (by automatically returning to that match or whatever).
I guess it's worth double checking in your device's Notification settings to see that your app has Notification Center alerts enabled.
您是否在 iTunes connect/配置门户中设置了推送通知?您实际上需要一个特殊的证书才能启用推送。
在我设置证书之前,我遇到了与您相同的问题。
Have you set push notifications up in iTunes connect / the provisioning portal? You actually need a special certificate to enable push.
I was having the same problem as you until I set up the certificates.