Multiplayer Invitations

The invitation system for the RTM(Real-Time Multiplayer) and TBM(Turn-Based Multiplayer) is mostly the same, with few minor differences which will be also described in this article.

There are 2 scenarios how we can receive / accept invitation and start new multiplayer match:

Receiving invitation when the app is running. 

If you want to be informed when player got new invitation while your app is running, you can subscribe for the ActionInvitationReceived event in GooglePlayInvitationManager class.  ActionInvitationReceived event will be fired only if you have registered the  invitation listener as showed bellow:


This method will register a listener to intercept incoming invitations for the currently signed-in user. If a listener is registered by this method, the incoming invitation will not generate a status bar notification as long as this client remains connected. You can also unregister it anytime you want using:


Note: Subscribing to this listeners is not necessary you can always implement only 2-nd offline scenario.

After Invitation listener is registered you can use ActionInvitationReceived and ActionInvitationRemoved  events as showed bellow:

GooglePlayInvitationManager.ActionInvitationReceived += ActionInvitationReceived;
GooglePlayInvitationManager.ActionInvitationRemoved += ActionInvitationRemoved;

private void ActionInvitationReceived(GP_Invite invitation) {
	//Hnadeling invitation code

private void ActionInvitationRemoved(string invitationId) {
	//Hnadeling invitation code

ActionInvitationReceived Callback invoked when a new invitation is received. This allows an app to respond to the invitation as appropriate. If the app receives this callback, the system will not display a notification for this invitation. 

ActionInvitationRemoved Callback invoked when a previously received invitation has been removed from the local device. For example, this might occur if the inviting player leaves the match.

Note: For TBM Multiplayer user will be invited only when he will have to do his first turn. User will not be invited right after TBM match is created.

After you was notified about new incoming invitation, you can choose how to handle it. You basically have two options handle invitation programmatically or use Google Play Inbox UI. To show Inbox UI you may sue following code:

//For RTM

//For TBM

Those methods will show user inbox UI, and will give user ability to accept / dismiss permission using Google UI. If you want to find out when inbox UI was closed, you can subscribe to the GooglePlayInvitationManager.ActionInvitationInboxClosed event. Handling inbox UI result is the same as Handling offline invitation result.

Receiving invitation when the app is closed

If user get's invitation while your app is closed, inactive or you wasn't registered for invitation listener. He will got clickable status bar invitation. Click on this invitation open's Google Play Service app with the list of user invites.  If user will accept invitation it will start the app. 

Real-Time Multiplayer :

Before connection to google play service we should subscribe to the  GooglePlayInvitationManager.ActionInvitationAccepted, see the snippet bellow:

GooglePlayConnection.ActionPlayerConnected += OnPlayerConnected;
GooglePlayConnection.ActionPlayerDisconnected += OnPlayerDisconnected;
GooglePlayInvitationManager.ActionInvitationAccepted += ActionInvitationAccepted;

GooglePlayConnection.Instance.Connect ();

void ActionInvitationAccepted (GP_Invite invitation) {

	//preparing multiplayer game for start 

If we the ActionInvitationAccepted is received it means that user already made a decision to accept the invitation using  Google Inbox UI or  Play Service app. So we need to accept it programmatically as well, no point to ask user again if he want's to accept this invitation. But before doing that, we can prepare our application to start the multiplayer game. For example: load multiplayer scene, subscribe to necessary listeners, initialize models, etc. After all done we should accept the invitation using GooglePlayRTM.instance.AcceptInvitation method. This will join us to the multiplayer room. The result is delivered by the GooglePlayRTM.ActionJoinedRoom event.

Turn-Based Multiplayer

If user accepting invitation for turn-based match unlike RTM invitation will be accepted automatically by google API, which mean we will not get ActionInvitationAccepted event. Instead ActionInvitationAccepted the GooglePlayTBM.ActionMatchInitiated will be fired. Which mean we should be prepeated to get it after connection to play service, the same as with the ActionInvitationAccepted for RTM

Accepting / Declining invitations programmatically

The incoming invitation is represented as GP_Invite object, including GP_InvitationType.

Accepting RTM invitation:

GooglePlayInvitationManager.ActionInvitationReceived += OnInvite;

private void OnInvite(GP_Invite invitation) {
	if (invitation.InvitationType != GP_InvitationType.INVITATION_TYPE_REAL_TIME) {



The result is delivered by the GooglePlayRTM.ActionJoinedRoom event. You can also use following methods for Dismiss / Decline the invitation:


Accepting TBM invitation:

GooglePlayInvitationManager.ActionInvitationReceived += OnInvite;

private void OnInvite(GP_Invite invitation) {
	if (invitation.InvitationType != GP_InvitationType.INVITATION_TYPE_REAL_TIME) {


The result is delivered by the GooglePlayTBM .ActionMatchInitiated event. You can also use following methods for Dismiss / Decline the invitation:


Warning: Make sure that before you accept the invitation, your game is ready to start multiplayer game, since accept invitation will result the same as create/join new match.


Google multiplayer exclusiveBitMask and variant

When you creating TBM and RTM match you can set exclusiveBitMask and variant. Here is short explanation of use cases for those parametrs.


This is an optional, developer-controlled parameter describing the type of game to play, and is used for auto-matching criteria. Must be either a positive integer or ROOM_VARIANT_DEFAULT (the default) if not desired.

Note that variants must match exactly. Thus, if you do not specify a variant, only other rooms created withROOM_VARIANT_DEFAULT will be considered potential auto-matches.

Example 1. We have a race game, and of course we want our matched player to race the same track, In this case we will use variant param to make sure that system will match users with the same track option.  

Example 2. If skill in our game means a lot, and we do not want to match new buys with the experienced player, we can use variant as level representation. For example for users with level from 1-5 we will set variant 1, for users with level 5-15, variant = 2. 15-30, variant =3, etc.

Exclusive Bit Mask

Your game can also use the exclusiveBitMask parameter  to pair auto-matched players who are interested in playing specific exclusive roles in a game. The exclusive bitmask of each pairing of players must equal zero for auto-match.

Example 1. We have different player roles in our game, and match should have 3 player with following roles: FARMER, ARCHER and WIZARD. Let's represend our roles as showed bellow 

private static int ROLE_FARMER = 0x1; // 001 in binary
private static int ROLE_ARCHER = 0x2; // 010 in binary
private static int ROLE_WIZARD = 0x4; // 100 in binary


In the case only 2 diffrent roles will give use zero result, same roles will give us non-zero result




So we can be sure that only player with diffrent roles can be matched together.