Search code examples
ios6cocos2d-iphonegame-center

chooseBestHostPlayerWithCompletionHandler returns null


The following code returns best host as null. How can I get it to work?

[gameKitHelper.match chooseBestHostPlayerWithCompletionHandler: ^(NSString *playerID) {
    gameKitHelper.hostingPlayer = [playerID retain];
    NSLog(@"Best host = %@",gameKitHelper.hostingPlayer);
}];

Solution

  • From Apple's Game Center Guide

    If you intend to search for the best server using this method, all devices in the match must be running on versions of Game Kit that support this method, and every device in the match must call this method at the same time.

    Do you do that in your app?

    Also in order for this to work all the clients must be already connected to each other.