GKTurnBasedMatch Network Issues

76 Views Asked by At

I've been trying to implement a way to notice when my app gets disconnected from Game Center since ending a turn while disconnected breaks the app. I just started testing on my iPad with the WiFi off and noticed that even when I completely quit the app, it automatically authenticates my player and signs me into game center. It even loads game data from recent games. I then tried going on the game center app itself and the only thing that caused a network error was clicking on the "Games" tab. Obviously much of the data is being cached so I don't know what to check to see if I'm disconnected.

So how can I test if the device is connected to Game Center? Neither Match data, participants, nor any of their properties are nil, and the player is always authenticated.

1

There are 1 best solutions below

0
On

Try to manage this with two things :

  • Network connection : with something like FXReachability and then [FXReachability isReachable]

  • Game Center authentification :

In your app test authentification with :

GKLocalPlayer.localPlayer.isAuthenticated

More generally, always test completion handlers errors and array existence like this :

[GKTurnBasedMatch loadMatchesWithCompletionHandler:^(NSArray *matches, NSError *error) {
if (error) {
    // what kind of error ?
}
if (matches) {
    // do what you need to do
}}];

Hope this will help you a little bit...