2013-05-09 33 views
1

我可以檢索所有遊戲中心的好友與此代碼...的iOS:找回比賽中心的朋友誰是在線

GKLocalPlayer *lp = [GKLocalPlayer localPlayer]; 
    if (lp.authenticated) 
    { 
     [lp loadFriendsWithCompletionHandler:^(NSArray *friends, NSError *error) 
     { 
      NSLog(@"MY FRIENDS: %@",friends); 
      if (friends != nil) 
      { 
       [GKPlayer loadPlayersForIdentifiers:friends withCompletionHandler:^(NSArray *players, NSError *error) 
        { 

         if (error != nil) 
         { 
          // Handle the error. 
          NSLog(@"PLAYERLIST ERROR: %@",[error localizedDescription]); 
         } 
         if (players != nil) 
         { 
          // Process the array of GKPlayer objects. 
          NSLog(@"PLAYERS: %@",players); 
         } 
        }]; 
      } 

     }]; 

    } 

...但是,有沒有辦法只檢索與的GameKit誰是朋友在線

+0

可能重複:http://stackoverflow.com/questions/3781195/how-do-i-get-a-gkplayers-status-from-game-center – giacomelli 2013-05-09 15:45:51

+0

我不相信這是一個副本。狀態屬性是否告訴玩家是否在線? – 2013-05-10 09:47:20

回答

2

它看起來不像你能夠。由於GKPlayer不提供任何查看玩家是否在線的方式。

另外,從技術上來說,一旦某人登錄到遊戲中心,他們就會「在線」直到他們註銷。這意味着他們可以在使用手機的同時在線數天。當他們登錄時,如果您向他們發送邀請,他們將獲得小號噪音。

http://developer.apple.com/library/IOS/#documentation/GameKit/Reference/GKPlayer_Ref/Reference/Reference.html#//apple_ref/doc/uid/TP40009599

相關問題