Google 玩游戏 API 和范围

Google Play Games API and Scope

长期以来,我一直在努力为我的问题找到一个好的答案。 我的问题有点简单。

当访问 Google Play Games API 时,Google 建议我们不要请求不必要的范围。

this post, 中,无需同意屏幕即可访问 API 的好方法示例如下:

 // This way you won’t get a consent screen  
 GoogleApiClient gac = new GoogleApiClient.Builder(this, this, this)  
           .addApi(Games.API)  
           .build();  
 // This way you won’t get a consent screen  

Play Game Services Guide中,他们给出了这个例子

// Create the Google Api Client with access to the Play Games services
mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .addApi(Games.API).addScope(Games.SCOPE_GAMES)
        // add other APIs and scopes here as needed
        .build();

所以我的问题是关于 "addScope(Games.SCOPE_GAMES)"。添加时,用户会看到一个同意屏幕,内容包括年龄范围、玩家资料和类似的东西,我不太记得了。

它有什么用?两者有什么区别? 如果我不使用它而只使用 addApi(Games.API) 而不添加范围,我无法访问什么

我的游戏只需要显示多人游戏的玩家用户名和玩家 ID。我需要添加范围吗?因为我真的不想让同意 window 在登录时无缘无故地出现。

谢谢。

Google Play Docs 所述,包括 getCurrentAccountName() 在内的几个函数需要 SCOPE_GAMES。所以如果你想显示你的玩家用户名,你需要添加范围。 (此外,对于用户名,需要权限:android.permission.GET_ACCOUNTS