4

I'm making a turn-based game, using the Game Center Turn-Based Gaming functionality. I'm using the simulator and my iPhone to test notifications of turn events. The results are very inconsistent. About 75% of the time when I make a move on the simulator and pass the turn I don't get any notifications on my iPhone. It seems that this function doesn't get called:

handleTurnEventForMatch:didBecomeActive:

I set the GKEventHandlerDelegate in the code that authenticates the local user and it seems to be set correctly. The fact that I get notifications once in a while suggests that this isn't where the problem lies.

Does anyone have any idea what could be the problem here? Could this be a problem with the Sandbox Game Center Server? Do they limit the amount of notifications you can send in a short amount of time or something like that?

Edit: I just found some posts of people experiencing the same problem, but no solution. No very recent posts though. Any updates?

Edit2: I also find that after a move, when I open the GKTurnBasedMatchmakerViewController on the other device it still says that it's the turn of the other player. When I close and reopen it the information is correct. Also, when I open the game GKTurnBasedMatchmakerViewController when it's still showing incorrect information, it does gives me the correct match object with the updated information. Could this be related in any way?

Bart
  • 1,077
  • 1
  • 12
  • 22
  • I am getting exactly the same sort of thing. It is very frustrating. I'm going to hope that the live version of the game center is as crappy as the sandbox. Also... I'm using the newer iOS 7 [[GKLocalPlayer localPlayer] registerListener:]; – AutomatonTec Nov 05 '13 at 10:26
  • 1
    I hope you mean "isn't as crappy" :p – Bart Nov 05 '13 at 13:28
  • I just switched to the [[GKLocalPlayer localPlayer] registerListener] as well. We still need to add the old one if we want to support iOS 6 right? – Bart Nov 05 '13 at 13:29
  • Any update on this? It's happening to me as well. If I refresh my game list, the data is correct, but I never receive the event. I don't really want to release my app if this is how it is going to behave in prod. – Ben L. Dec 15 '13 at 03:45
  • 1
    Nope. It's still unclear what's causing this, but the consensus seems to be that it's a problem with the Sandbox server and that it shouldn't occur in production. But nobody seems sure. – Bart Dec 16 '13 at 08:13
  • 2
    I am also experiencing this issue with code that has been working flawlessly for over 6 months. I think it is a sandbox issue. Something of note is that if I go into the Game Center app and view my turns (the last item on the tab bar on the bottom) it will refresh my matches properly and show the turns taken. Then, if I go into my game and reload the matches, the information is correct. Obviously this is an issue on Apple's side, but using this trick I have been able to (sort of) continue testing my code. NOTE: I use custom UI for showing and creating matches, not the default view controller. – Corbin87 Dec 29 '13 at 18:49
  • I'm having the same problem as many others (esp. Corbin87), and have detailed it quite extensively here: http://stackoverflow.com/questions/20906784/gkturnbasedeventhandler-delegate-is-not-receiving-any-messages – Zane Claes Jan 03 '14 at 22:07
  • By the way: did you other guys ever find a solution? If you've released your app, did it work right in prod? @Bart etc. – Zane Claes Jan 03 '14 at 22:37
  • I haven't released yet, and strangely nobody seems to know what will happen in production. – Bart Jan 06 '14 at 11:40

2 Answers2

1

I thought I would share my solution with you, in the hopes that it is the same problem you are experiencing. As you can see from my comment to your question, I was having the same issue as you. It turned out that my settings in iTunes Connect were the culprit, unbeknownst to me. What you should check for is that you still have Game Center enabled in BOTH places that iTunes Connect requires. First, after going into "Manage my Apps" in iTunes Connect, select your app and on the right menu, and click "Manage Game Center". Make sure this is currently enabled. I would even recommend disabling it, and re-enabling it again for good measure.

In addition (and this is what I was missing), you must enable it in one more place. Go back to the previous screen when you first select the app. The top right is where you can select Manage Game Center, but we are looking on the bottom in the "Versions" section. Click the View Details button for your app, and make sure the Game Center button is enabled near the bottom. Again, I would disable and re-enable it here as well. Give it about 10 minutes, clear all your open turns and matches from the Game Center app (this might be an optional step), and build & run again. Hopefully, you will receive turn notifications properly again.

Corbin87
  • 538
  • 4
  • 12
  • Thanks, for me I have not turned on the GameCenter under the app details page. And also do you know any difference between - (void)handleTurnEventForMatch:(GKTurnBasedMatch *)match didBecomeActive:(BOOL)didBecomeActive and - (void)handleTurnEventForMatch:(GKTurnBasedMatch *)match didBecomeActive. In a tutorial in raywenderlich, the second one was used without "didBecomeActive:(BOOL)didBecomeActive". – MTahir Mar 24 '14 at 13:52
  • I am using a device and simulator to test, how long does it take to transfer the turn ? – MTahir Mar 24 '14 at 14:04
  • MTahir: The method without didBecomeActive was used in iOS6 and prior and has since been deprecated. Reference the GKTurnBasedEventHandlerDelegate Protocol information in Apple's developer library if you are unsure of certain methods. As for the simulator, turn notifications are not received when using that, only when running on actual devices. Even that can be finicky at times thanks to the unreliable Game Center sandbox servers. – Corbin87 Mar 24 '14 at 22:31
  • When I end turn on simulator, and app on device is in background, a notification is received instantly, but when tap on notification to open the app, gamestate is still the old one, do I have to manually check for updated match state now ? – MTahir Mar 25 '14 at 06:47
0

I got the same problem. However when i tested it on multiple devices it was working fine... May be some problem with the simulator

Umesh Sharma
  • 388
  • 5
  • 23
  • On devices I encounter the same problem. Are you sure you didn't just get a lucky streak of turns? Sometimes it works for 3 turns in a row or something, and then it fails again. – Bart Jan 08 '14 at 13:04
  • let me try on that... but on my simulator this problem occurs frequently... And i have tested it more than 3 turns :) . Also on raywendelich's tutorial i foun that notifications are inconsistent... here is the link incase you want to check http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 – Umesh Sharma Jan 08 '14 at 14:54