How do I get notifications for GameKit Turn-Based matches?
Asked Answered
C

4

12

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

Coachwork answered 28/10, 2011 at 21:57 Comment(2)
Hey John, have you figured this out yet? I'm about to implement all this stuff in a game myself. Hope it's not too terrible!Sosthina
Plz check my question #16266589, I dont understand why I am not getting the notification in the otehr device. Could be the issu related with handleInviteFromGameCenter or GKTurnBasedEventHandlerDelegate??Purree
W
14

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;

Willettawillette answered 30/11, 2011 at 22:30 Comment(0)
A
1

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

Advice answered 6/1, 2013 at 0:18 Comment(0)
S
0

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.

Sandstorm answered 31/3, 2012 at 23:54 Comment(0)
M
-1

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.

Moshe answered 18/11, 2011 at 22:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.