GKTurnBasedEventHandler delegate not receiving messages

I used [[GKTurnBasedEventHandler sharedTurnBasedEventHandler] setDelegate:self];, but I do not receive delegate calls. It worked at some point, and I can’t understand how much my life has changed.

The application is properly encrypted (the icon with the number of games where it is on my turn is displayed on the main screen of the device). In addition, use is GKTurnBasedMatch loadMatchesWithCompletionHandler:able to detect when a player is turning (or not). In fact, in any other possible way, GameCenter seems to work just fine. I can even send (and receive) calls, but again, the delegate methods are not called: none of the methods GKTurnBasedEventHandlerDelegateare called (including handleTurnEventForMatch:, handleInviteFromGameCenter:etc.)

It becomes even weirder: if I completely leave the application and it becomes my turn, I do not see the GameCenter notification. However, I DO placed the icon in my application! if I just open the GameCenter application, I also see that it is my turn. Thus, even OS level notifications are not accepted, despite the fact that the data is correctly updated on the server ...

I heard that maybe the GameCenter Sandbox is just unreliable with the delivery of notifications ... but I really can't risk it. I need to check my code!

Things I tried:

  • Make sure I'm testing on real devices (no simulators). I tested 4 real devices, including iPhones + iPads and iOS6 + iOS7.
  • NSAssert([GKTurnBasedEventHandler sharedTurnBasedEventHandler].delegate == self 60 , , ( : handleTurnEventForMatch: didBecomeActive: )
  • , push-
  • , iTunesConnect version CFBundleShortVersionString info.plist (0.0.1) iTunesConnect GameCenter "" . CFBundleVersion , , .
  • #s 3. 1.0.0 1.0 0.1 .. NSLog, , .
  • , , developer.apple.com, XCode GameCenter Capabilities. (, , "", , Provisioning Profile ).
  • push-. ( ) , , , APN-.
  • ... . , , . 10 , , ( , ).

: Sandbox [[GKLocalPlayer localPlayer] registerListener:self] GKTurnBasedEventHandler. , . SDK, 7.0 ( 7+).

+2
2

, GameCenter Sandbox , , . , GameCenter .

DUMB. DEBUG, handleTurnEventForMatch. ... .

, . . onMultiplayerGameStarted onEndedMultiplayerTurn .

#if GAMEKIT_TURN_POLLING

NSMutableDictionary *_wasLocalPlayersTurnMap = nil;

- (void)pollGameCenter {
  if(!_wasLocalPlayersTurnMap) {
    _wasLocalPlayersTurnMap = [NSMutableDictionary new];
  }
  [AMGameData loadGames:^(NSArray *games) {
    NSInteger validGameCount = 0;
    for(AMGameData *gameData in games) {
      if(gameData.isSinglePlayer) {
        continue;
      }
      if(gameData.gameState != AMGameStatePlaying) {
        continue;
      }
      validGameCount++;
      if([_wasLocalPlayersTurnMap[gameData.name] boolValue]) {
        continue;
      }
      if(!gameData.isLocalPlayersTurn) {
        _wasLocalPlayersTurnMap[gameData.name] = @(NO);
        continue;
      }
      // Hey, it now our turn!
      _wasLocalPlayersTurnMap[gameData.name] = @(YES);
      [self handleTurnEventForMatch:gameData.match didBecomeActive:NO];
    }
    if(validGameCount) {
      // Need to do this again later...
      [self delayedPollGameCenter];
    }
  }];
}

- (void)delayedPollGameCenter {
  [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(pollGameCenter) object:nil];
  [self performSelector:@selector(pollGameCenter) withObject:nil afterDelay:10];
}

- (void)onMultiplayerGameStarted {
  [self delayedPollGameCenter];
}

- (void)onEndedMultiplayerTurn:(AMGameData*)gameData {
  _wasLocalPlayersTurnMap[gameData.name] = @(NO);
  [self delayedPollGameCenter];
}

#else
- (void)onMultiplayerGameStarted{}
- (void)onEndedMultiplayerTurn:(AMGameData*)gameData {}
#endif
+1

All Articles