Reputation: 3964
I am following the TBMP Skeleton app to create my own TurnBased Multiplayer
game.
I tried using these methods to handle notifications but they are never called:
@Override
public void onInvitationReceived(Invitation invitation) {
Toast.makeText(
this,
"An invitation has arrived from "
+ invitation.getInviter().getDisplayName(), TOAST_DELAY)
.show();
}
@Override
public void onTurnBasedMatchReceived(TurnBasedMatch match) {
Toast.makeText(this, "A match was updated.", TOAST_DELAY).show();
}
Does anybody know why these methods aren't called when a player clicks on a game notification?
And alternatively, if these methods are never being called, how does Google API
handle my receiving notifications?
My notification messages say instead: Player1 invites you to a match of Skeleton Tbmp
and It's your turn in a match of Tbmp Skeleton with Player1
Upvotes: 0
Views: 118
Reputation: 51
(Just adding some detail to the existing answer here for future searchers)
You need to register an invitation/match update listener. See Games.Invitations.registerInvitationListener.
Note, though, that these listeners do not run when your game is not running. In that case, the user will get a system notification instead. This also means that if you do use these listeners in your game, no notification will appear in the system tray.
Upvotes: 0
Reputation: 3964
Turns out I was missing these lines:
Games.Invitations.registerInvitationListener(getApiClient(), this);
Games.TurnBasedMultiplayer.registerMatchUpdateListener(getApiClient(), this);
Upvotes: 1