Google Play Games

后端 未结 3 1846
逝去的感伤
逝去的感伤 2020-12-11 13:33

Good day everyone.

I\'m trying to implement Achievements in a game I\'m developing.

I already set everything on google play console, got the app-id, put in t

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-11 14:10

    I think you should check:

    GoogleSignIn.hasPermissions(account, Games.SCOPE_GAMES_LITE).
    

    And if there is no permissions in that account you should use

    GoogleSignIn.getClient(this, gso).silentSignIn or GoogleSignIn.getClient(this, gso).getSignInIntent() 
    

    with startActivityForResult to receive account with GAMES_LITE scope.

    GoogleSignIn.hasPermissions also returns false for null account which could be also result of the getLastSignedInAccount.

    Example:

    GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
    
    if (GoogleSignIn.hasPermissions(account, Games.SCOPE_GAMES_LITE)) {
        onSignIn(account);
    } else {
        signInClient
          .silentSignIn()
          .addOnCompleteListener(
              this,
              task -> {
                if (task.isSuccessful()) {
                  onSignIn(task.getResult());
                } else {
                  resetSignedIn();
                }
              });
    }
    

提交回复
热议问题