Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

player:receivedTurnEventForMatch:didBecomeActive: inconsistently/rarely fires

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?

like image 381
Ben Pious Avatar asked Dec 12 '13 20:12

Ben Pious


2 Answers

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.

like image 52
Serge Avatar answered Sep 20 '22 00:09

Serge


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.

like image 21
Ben Pious Avatar answered Sep 19 '22 00:09

Ben Pious