8

This is a follow-up to this question. If you are not receiving any callbacks to handleTurnEventForMatch:didBecomeActive:, try the answer there.

In my game, I am only receiving turn event notifications some of the time. But if I go back to the matchMakerViewController and re-load the match, the state is always correct.

My game uploads the turn state multiple times during each turn. Anecdotally, it seems that if the other device receives one notification for an opponent's turn, it is less likely to receive further notifications for that same turn. However, this is not 100%.

In general, my internet connection seems to work pretty well.

Any ideas what might be causing this?

Community
  • 1
  • 1
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
  • Have the same issue. When application is launched handleTurnEventForMatch method called for the same match times to time. – Serge Feb 18 '13 at 13:33
  • Having exactly the same problem. Most of the time only one device can send to the other, and the other can't reply. But it's the one-way direction is different from match to match. – Theis Egeberg Mar 10 '13 at 12:11

1 Answers1

9

I finally figured out the problem.

Alright, if you use the GKTurnBasedMatchmakerViewController, then it steals the delegation from your current delegate.

It has probably got something like:

[GKTurnBasedEventHandler sharedTurnBasedEventHandler].delegate = self;

This makes perfect sense as the viewcontroller needs to update when changes occur from gamecenter, so it becomes the delegate for the GKTurnBasedEventHandler.

If you want to return the delegation to your own object though you should put this line:

[GKTurnBasedEventHandler sharedTurnBasedEventHandler].delegate = self;

At the very top of all function in the GKTurnBasedMatchmakerViewControllerDelegate protocol.

Anupdas
  • 10,211
  • 2
  • 35
  • 60
Theis Egeberg
  • 2,556
  • 21
  • 30
  • 2
    You just save me a ton of time. Thanks! – Daniel Duan Apr 25 '13 at 04:15
  • I'm glad this works for some people. Alas, it does not appear to be working for me. – William Jockusch Apr 27 '13 at 00:49
  • 1
    I'm having the same problem but your suggested solution does not help (on iOS 6.1.x i.e.). I'm asserting that the delegate is still what I want it to be at the very top of all functions in the said protocol, and none of these fails. If Apple were to steal the delegate in its implementation of GKTurnBasedMatchmakerViewController, why would it not restore the value before calling any of these functions? – Drux Oct 03 '13 at 20:32
  • It was the only reason,`handleTurnEventForMatch` was not getting called. +1 – MTahir Apr 10 '14 at 18:03