Player: receivedTurnEventForMatch: didBecomeActive: inconsistent / rarely works

I am currently testing the Game Center Aware application using the Gamebox Sandbox, with one instance running on the iOS simulator and the other running on the Retina iPad Mini. I have a view controller that should receive rotation events, so I implement a method

player:receivedTurnEventForMatch:didBecomeActive: 

in the GKLocalPlayerListener protocol, which takes my subclass of UIViewController, and then logs for events with this line

 [[GKLocalPlayer localPlayer] registerListener: self]; 

in the init method of the view controller. However, despite the fact that the Game Center application says that both instances of the game are connected, this method is rarely called an iPad, and I don’t think I have ever seen an instance of a simulator name it. However, going to the Game Center app shows that both instances are updated, indicating that both instances are capable of receiving the event. What could be the reason for this?

+6
source share
2 answers

I had the same problem on iOS 7 / Xcode 5 / iPhone 5. To fix this problem, you just need to add the right to the “Game Center” to your application ID. You can do this by going to the Features tab in Xcode.

Note that player:receivedTurnEventForMatch:didBecomeActive: will only run on devices.

+2
source

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

 loadMatchDataWithCompletionHandler: 

when the refresh button is pressed in the user interface, which leads to the loading of the matching data in the simulator.

+1
source

All Articles