繁体   English   中英

iOS:检索在线的Game Center朋友

[英]iOS: Retrieve Game Center friends who are online

我可以使用此代码检索所有Game Center朋友...

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检索在线的朋友?

看起来您不具备能力。 由于GKPlayer不提供任何方式查看播放器是否在线。

同样,从技术上讲,一旦一个人登录Game Center,他们就一直处于“在线”状态,直到他们注销为止。 这意味着他们可以在使用手机的情况下在线几天。 如果您发送邀请,则在他们登录后,他们会听到小号声。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM