Let’s start…
APP NOT CORRECTLY CONFIGURED TO USE GOOGLE PLAY SERVICES
The script (I then call the functions from it in the game):
using System;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using GooglePlayGames.BasicApi.SavedGame;
using UnityEngine;
public static class GPGSAPI
{
public const string saveName = "SAVE";
public static bool IsAuth {
get
{
if (PlayGamesPlatform.Instance != null)
return PlayGamesPlatform.Instance.IsAuthenticated();
return false;
}
}
public static ISavedGameMetadata game;
public static ISavedGameClient client;
public static DateTime startDateTime;
public static void Initialize(bool debug)
{
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.EnableSavedGames()
.RequestEmail()
.RequestServerAuthCode(false)
.RequestIdToken()
.Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = debug;
PlayGamesPlatform.Activate();
startDateTime = DateTime.Now;
}
public static void Authenticate(bool mode, Action<bool> result)
{
PlayGamesPlatform.Instance.Authenticate((obj) =>
{
if (obj) client = PlayGamesPlatform.Instance.SavedGame;
result(obj);
}, mode);
}
public static void GetAchievement(string id, Action<bool> result)
{
Social.ReportProgress(id, 100.0f, result);
}
public static void SetScoreToLeaderboard(string id, long score, Action<bool> result)
{
Social.ReportScore(score, id, result);
}
public static void ShowAchievementUI()
{
Social.ShowAchievementsUI();
}
public static void ShowLeaderboardsUI()
{
Social.ShowLeaderboardUI();
}
public static void SignOut()
{
PlayGamesPlatform.Instance.SignOut();
}
public static void OpenSave(Action<SavedGameRequestStatus, ISavedGameMetadata> result)
{
if (!IsAuth)
{
result(SavedGameRequestStatus.AuthenticationError, null);
return;
}
client.OpenWithAutomaticConflictResolution(saveName, DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseLongestPlaytime, result);
}
public static void ReadSave(Action<SavedGameRequestStatus, byte[]> result)
{
if (!IsAuth)
{
result(SavedGameRequestStatus.AuthenticationError, null);
return;
}
OpenSave((st, md) =>
{
if (st == SavedGameRequestStatus.Success)
{
client.ReadBinaryData(md, result);
game = md;
}
else result(SavedGameRequestStatus.InternalError, null);
});
}
public static void WriteSave(byte[] data, Action<bool> result)
{
if (!IsAuth || data == null || data.Length == 0)
{
result(false);
return;
}
TimeSpan curSpan = DateTime.Now - startDateTime;
Action onDataWrite = () =>
{
TimeSpan totalPlayTime = curSpan + game.TotalTimePlayed;
SavedGameMetadataUpdate.Builder builder = new SavedGameMetadataUpdate.Builder()
.WithUpdatedDescription("Save at " + totalPlayTime.ToString())
.WithUpdatedPlayedTime(totalPlayTime);
SavedGameMetadataUpdate update = builder.Build();
client.CommitUpdate(game, update, data, (s, m) =>
{
if (s == SavedGameRequestStatus.Success)
{
game = m;
result(true);
}
else
result(false);
});
startDateTime = DateTime.Now;
};
if (game == null)
{
OpenSave((s, m) =>
{
if (s == SavedGameRequestStatus.Success)
{
game = m;
onDataWrite();
}
else result(false);
});
return;
}
onDataWrite();
}
}
Two credentials in the Google Play Console: one with a simple key, the other with a key that GP (Google Play, I will write this way) signs applications. 50 achievements, 3 ratings. I tried to download from GP, installed APK right after assembly, cleaned the data of GP games, / u003 before APP_ID is.
The Web Client ID comes from a regular key, it doesn’t work on a regular one either. I catch an error when it auntithicates. I don’t know what he needs. I recreated the accounts several times. Also I have GoogleMobileAds plugin and Unity IAP.
HELP!!!