Google Play Games Android排行榜意外响应代码410

本文关键字:响应 代码 意外 排行榜 Play Games Android Google | 更新日期: 2023-09-27 18:05:16

我正在Unity中执行Google Play Games排行榜,我正在制作查看排行榜的UI,为此,我使用:

SDK: https://github.com/playgameservices/play-games-plugin-for-unity

Google Play Service版本:9.4.0

当我使用LoadScores方法从PlayGamesPlatform类没关系,返回用户,分数等,但是,为了获得更多的用户,我需要使用LoadMoreScores方法,这里是问题。

当我使用LoadMoreScores方法时,在日志中,Android返回那个并且不返回更多的玩家:

E/Volley: [5566] BasicNetwork.performRequest: Unexpected response code 410 for https://www.googleapis.com/games/v1/leaderboards/LeaderboardID/window/PUBLIC?timeSpan=ALL_TIME&language=en_US&maxResults=10&pageToken=LeaderboardNextToken&returnTopIfAbsent=true
W/LeaderboardAgent: Failed to retrieve leaderboard scores for GameID LeaderboardID ALL_TIME
                                                     com.android.volley.ServerError
                                                         at com.android.volley.toolbox.BasicNetwork.performRequest(:com.google.android.gms:163)
                                                         at iss.performRequest(:com.google.android.gms:64)
                                                         at com.android.volley.NetworkDispatcher.run(:com.google.android.gms:113)
W/LeaderboardAgent: {"errors":[{"domain":"global","reason":"PaginationTokenInvalid","message":"The passed token does not match the arguments of the request. Token: LeaderboardNextToken"}],"code":410}

我在Unity3D中对这个错误的代码是:

/// <summary>
/// Loads the scores using the provided parameters.
/// </summary>
/// <param name="leaderboardId">Leaderboard identifier.</param>
/// <param name="start">Start either top scores, or player centered.</param>
/// <param name="rowCount">Row count. the number of rows to return.</param>
/// <param name="collection">Collection. social or public</param>
/// <param name="timeSpan">Time span. daily, weekly, all-time</param>
/// <param name="callback">Callback to invoke when completed.</param>
PlayGamesPlatform.Instance.LoadScores(
            "LeaderboardID", //The original ID obviously
            LeaderboardStart.PlayerCentered,
            10,
            LeaderboardCollection.Public, 
            LeaderboardTimeSpan.AllTime,
            (success) =>
            {
                leaderboardScoreData = success;
                //Do Anything...
            }
);

LoadScores

/// <summary>
/// Loads more scores.
/// </summary>
/// <remarks>This is used to load the next "page" of scores. </remarks>
/// <param name="token">Token used to recording the loading.</param>
/// <param name="rowCount">Row count.</param>
/// <param name="callback">Callback invoked when complete.</param>
PlayGamesPlatform.Instance.LoadMoreScores(
    leaderboardScoreData.NextPageToken,
    10,
    (success) =>
    {
        //Looking the returned object
        Debug.Log("Load more scores info: " + success.ToString());
        //Do Anything...
    }
);
Debug.Log返回:
I/Unity: Load more scores info: [LeaderboardScoreData: mId=LeaderboardID,  mStatus=SuccessWithStale, mApproxCount=0, mTitle=]

下一页令牌和上一页令牌有一个正确的令牌,但Google play服务不能使用,mTitle在LeaderboardScoreData中是空的。

谁能告诉我如何修复这个标记错误?

我可以用其他方法获得其他分数吗?我不能再次使用LoadScore因为重新开始加载用户周围的用户,或者如果我能做到,我不知道怎么做。

Google Play Games Android排行榜意外响应代码410

对于将来的问题,最后的修复是:

在https://console.developers.google.com/apis/dashboard中激活Google Play Services,令牌将正常工作