Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine the match selected from a Google Play Games turnbased notification

When a user receives, and taps, on a turn based notification the default UI pops up allowing them to select which turn/invite to proceed with. This then launches my game.

However I cannot figure out how to determine which turn/invite the user selected and load the respective match automatically.

At the moment I am forced to reshow the default match inbox UI and react to the intent from it.

like image 868
Eoin Avatar asked Nov 25 '25 13:11

Eoin


1 Answers

I have this

TurnBasedMatch aMatch = getGameHelper().getTurnBasedMatch();
if (aMatch != null) {
    // GameHelper will cache any connection hint it gets. In this case,
    // it can cache a TurnBasedMatch that it got from choosing a
    // turn-based
    // game notification. If that's the case, you should go straight
    // into
    // the game.
    updateMatch(aMatch);
    return;
}

in my main activity, and I just found it in the sample SkeletonActivity where I must have copied it from. The idea is that as your main activity is launched, if you've used the standard BaseGameActivity base class, it authenticates and logs in automatically, and once it signs in, the Game Helper instance is able to retrieve the Match from whatever externally induced intent or hint available.

This GameHelper class is part of the BaseGameUtils "library" that the quick start guide suggests to use. This GameHelper gets the match from the Bundle provided in onConnected() of the Client library.

TurnBasedMatch match = connectionHint
    .getParcelable(GamesClient.EXTRA_TURN_BASED_MATCH);
like image 107
Rob D O'Connell Jr Avatar answered Nov 28 '25 04:11

Rob D O'Connell Jr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!