GKMatchmaker findMatchForRequest invite never received

前端 未结 3 1750
轻奢々
轻奢々 2021-01-19 00:13

I\'m trying to invite nearby players to a match, but the invite is either never sent or never received.

GKMatchMaker startBrowsingForNearbyPlayersWithHandler works

3条回答
  •  终归单人心
    2021-01-19 00:30

    I know this an older post, but I ran across it when trying to establish a connection between several app instances over the internet. I believe the part you're missing is that after registering for the listener, you need to receive the connected status with

        - (void)match:(GKMatch *)match
            player:(GKPlayer *)player
            didChangeConnectionState:(GKPlayerConnectionState)state
     {
         NSLog(@">>> did change state");
    
         if (state == GKPlayerStateConnected)
         {
             NSLog(@">>>> match:%@ did change to Connected for player %@ ",match, player.displayName);
    
         }
       else if (state == GKPlayerStateDisconnected)
       {
        NSLog(@">>>> match:%@ disconnected for player %@ ",match, player.displayName);
       }
    

    I find the match has 0 players when the completionHandler is called from findMatchForRequest:, but that I can successfully use the GKMatch and GKPlayer as returned in didChangeConnectionState: Hope that helps someone who reads this long after the OP.

提交回复
热议问题