player:receivedTurnEventForMatch:didBecomeActive: inconsistently/rarely fires

730 views Asked by At

I am currently testing my Game Center Aware App using the Game Center Sandbox, with one instance running on the iOS simulator and the other on an Retina iPad Mini. I have a view controller which needs to receive turn events, so I implement the method

player:receivedTurnEventForMatch:didBecomeActive:

in the GKLocalPlayerListener protocol, which my UIViewController subclass adopts, and then register for events with this line

[[GKLocalPlayer localPlayer] registerListener: self];

in the init method of the view controller. However, despite the Game Center App saying that the two instances of the game have connected, this method is rarely called on the iPad, and I dont't think I've ever seen the simulator instance calling it. However, going to the Game Center App shows that both instances are updated, showing that both instances are capable of receiving the event. What could be causing this?

2

There are 2 answers

5
Serge On

I had the same problem on iOS 7/Xcode 5/iPhone 5. To fix that issue you need just add "Game Center" entitlement to your App ID. You can do that by navigating to project's "Capabilities" tab in Xcode.

Please note that player:receivedTurnEventForMatch:didBecomeActive: will be fired on devices only.

0
Ben Pious On

The workaround I found for this issue on the simulator is to call the

loadMatchDataWithCompletionHandler:

method when a refresh button is pushed in the UI, which causes match data to be loaded in the simulator.