Search code examples
c#androidgoogle-playmaui

Implement PlayGameServices snapshots on MAUI game


I'm working on a little game using a MAUI (.NET 8) project, and currently, I'm working on saving the game status. I have no problem with the Windows platform, but although I've done everything needed to sign in to Google Play Games on the Android platform (which also works well), my problem lies in trying to save the snapshots, as it seems that this hasn't been implemented in the Xamarin.GooglePlayServices.Games.V2 package.

This is the demo code I found on developers.google.com:

private static final int RC_SAVED_GAMES = 9009;
private void showSavedGamesUI() {
SnapshotsClient snapshotsClient =
  PlayGames.getSnapshotsClient(this);
int maxNumberOfSavedGamesToShow = 5;

Task<Intent> intentTask = snapshotsClient.getSelectSnapshotIntent(
  "See My Saves", true, true, maxNumberOfSavedGamesToShow);

intentTask.addOnSuccessListener(new OnSuccessListener<Intent>() {
@Override
public void onSuccess(Intent intent) {
  startActivityForResult(intent, RC_SAVED_GAMES);
}
});
}

I should be able to do something like this:

var test  = PlayGames.GetSnapshotsClient(_activity);

But GetSnapshotsClient doesn't exist, and I cannot find anything related to this matter.

Am I missing something? Perhaps another NuGet package, or maybe there's another way to save the game status?

I'd appreciate any help on this.

Thanks in advance.


Solution

  • There is an known issue about Binding for com.google.android.gms.games.snapshot. And the Author said:

    I have tried the latest version of Xamarin.GooglePlayServices.Games.V2, and there is no PlayGames.GetSnapshotClient() that I think is needed :-(

    You can follow up this issue or report this as an new issue.