MrStahlfelge / gdx-gamesvcs

Easy integration of gameservices in your libGDX game: Google Play Games, Apple Game Center, Amazon GameCircle and more
Apache License 2.0
113 stars 20 forks source link

android-gpgs: GpgsClient using deprecated Google APIs #45

Open karivatj opened 2 years ago

karivatj commented 2 years ago

Hello,

I've been using your library for integrating Google Play Services to my game project, and it has been working fine when I'm running it on desktop (using desktop-gpgs module implementation). Leaderboards work as they should etc. However I noticed that on Android the leaderboards seem to respond with an empty payload even though the leaderboard id is correct, it is published and there are scores in it. I'm not sure if I'm using the library incorrectly or not, but here are my two cents that came to mind.

I downloaded the source code and checked that what's happening when I trigger fetchLeaderboardEntries method. The library is using deprecated Google APIs. For example, Games.Leaderboards.loadTopScores on line 477 of android-gpgs / GpgsClient.java has been deprecated since 2020-11-09. One should migrate to LeaderboardsClient instead.

There were other deprecated method calls within the client also that should be checked. Maybe using these deprecated APIs is causing some issues on android?

Also on another note I noticed that when fetching the leaderboards the timespan of the scores is hardcoded to be ALL_TIME. It would be great if you could specify the timespan yourself (DAILY, WEEKLY, ALL_TIME) so it would be possible to implement daily, weekly and all time leaderboards easily. It would be easy to implement by adding a new argument timespan of type integer in to the mix.

Thanks again for the good library. I'm not sure tho if this project is active anymore but if you could consider refactoring the android gpgs client code to use the up-to-date APIs it would be greatly appreciated.

image

MrStahlfelge commented 2 years ago

Feel free to open a PR with the changes. The lib is still maintained, but I usually don't change working code just for the sake of it.