ios - 游戏中心。获取真实姓名

标签 ios game-center

我想知道本地播放器的真实姓名,但是GKLocalPlayer的displayName返回的是“我”,而不是真实姓名。

编码我使用的:

 void (^completitionHandler)(NSArray *, NSError *) = ^(NSArray *players, NSError *error) { 

    for (GKPlayer *p in players) {
      NSString *alies = p.alies;
      NSString *name = p.displayName;
      NSLog(@"name = %@",name);   //not real name, just "Me"
    }

 }

最佳答案

不确定displayName可用于检索本地用户全名。来自 Apple's documentation :

Player Objects Provide Details About Players

When your game needs details for a particular player, it retrieves those details by making a query to Game Center. You retrieve information for a player using that player’s player identifier. Game Kit returns those details to your game in a GKPlayer object.

  • displayName:

    A user-readable string you can display for this player in your own user interface. For example, in a network match, you might show the display names for each player in the match so that everyone knows who they are playing against.

    The display name for a player depends on whether the player is a friend of the local player authenticated on the device. If the player is a friend of the local player, then the display name is the actual name of the player. If the player is not a friend, then the display name is the player’s alias.

它的目的是检索其他玩家的名字。然后,如果您要求本地播放器的显示名称,返回“Me”是有意义的,因为您是该设备的当前用户。我想这与隐私政策有关。

可能的解决方法:

或许,您可以获取本地用户 ID 并使用它来尝试从该 ID 的玩家列表中检索真实姓名。但是不知道会不会被当成你自己的 friend 。

关于ios - 游戏中心。获取真实姓名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15385236/

相关文章:

ios - Xamarin.Forms:在 iOS 上启用深色模式时,禁用的条目具有白色 TextColor

ios - 从 Fabric 获取崩溃日志 : iOS

ios - 是否可以构建和发布使用更新 API 的 iOS 应用程序?

ios - 恢复应用内购买

iphone - GameCenter 整合并发症?

iphone - ManagedObjectContext 保存导致 NSManagedObject 数据损坏/失效

android - Air StageWebView Leaflet map 图像在 Android 上呈锯齿状

sprite-kit - 游戏中心上不同的高分类型

c# - iOS 中的游戏中心 : GKScore vs. GKachievement?

ios - 将 objective-c 转换为 swift - GameKit