GPGS Multiplayer: Knowing my app was opened because of an accepted invitation

Hello everyone and happy holydays, in regards to the GPGS plugin:

  1. How do I know my app was opened because of the user accepting a GPGS Multiplayer Invitation, and which one?

So far here’s what I get:

  1. I get a notification on the “Google Play Games” app

  2. I “Accept” the invitation inside the “Google Play Games” app

  3. My Corona app starts

  4. Nothing happens

I know I can use the gpgs.multiplayer.invitations.load() function and receiving a “load” event with all my invitations ids, but here is not the answer because is not considering opening the app not from accepting an invitation, in which case it shouldn’t go right into the multiplayer game screen. At least I don’t see that behavior on “Block Puzzle King”, game used for usage reference. ( https://play.google.com/store/apps/details?id=com.mobirix.blockpuzzle&hl=en

thanks :slight_smile:

Look up “launchArgs”. There is a good chance you’re getting them that way. It could also be a push notification type event.

Rob

Thanks Rob, but I get nothing so far. I have this on my main.lua file:

local function notificationListener( event ) print("notificationListener: event.type", event.type) if ( event.type == "remote" ) then elseif ( event.type == "remoteRegistration" ) then elseif ( event.type == "local" ) then end end Runtime:addEventListener( "notification", notificationListener ) local launchArgs = ... if ( launchArgs and launchArgs.notification ) then notificationListener( launchArgs.notification ) end

I think the answer could be around this:
 

If you send an invite to a player with the game NOT running, Google Play Services on his phone should receive a request. The player can then accept or decline that invitation.

If he accepts the invitation, your game will be launched, and the ConnectionCallbacks.onConnected() will be triggered with a bundle containing the GamesClient.EXTRA_INVITATION. Using this invitation object, you can join the appropriate room.

Please note that I already encountered a bug in Google Play Services SDK ver. 3.2.65 - in which the bundle in the onConnected callback doesn’t return the invitation id. This seems to be fixed in 4.0.30.

source: http://stackoverflow.com/questions/21516856/google-play-multi-player-how-to-receive-the-invite-when-the-app-is-closed

Do you have a listener setup to handle invitations:

https://docs.coronalabs.com/plugin/gpgs/multiplayer/invitations/index.html

Rob

Yes, and when I’m inside the app and get an invitation, it works. But when I’m opening the app because of accepting an invitation on Play Games, nothing shows.

Look up “launchArgs”. There is a good chance you’re getting them that way. It could also be a push notification type event.

Rob

Thanks Rob, but I get nothing so far. I have this on my main.lua file:

local function notificationListener( event ) print("notificationListener: event.type", event.type) if ( event.type == "remote" ) then elseif ( event.type == "remoteRegistration" ) then elseif ( event.type == "local" ) then end end Runtime:addEventListener( "notification", notificationListener ) local launchArgs = ... if ( launchArgs and launchArgs.notification ) then notificationListener( launchArgs.notification ) end

I think the answer could be around this:
 

If you send an invite to a player with the game NOT running, Google Play Services on his phone should receive a request. The player can then accept or decline that invitation.

If he accepts the invitation, your game will be launched, and the ConnectionCallbacks.onConnected() will be triggered with a bundle containing the GamesClient.EXTRA_INVITATION. Using this invitation object, you can join the appropriate room.

Please note that I already encountered a bug in Google Play Services SDK ver. 3.2.65 - in which the bundle in the onConnected callback doesn’t return the invitation id. This seems to be fixed in 4.0.30.

source: http://stackoverflow.com/questions/21516856/google-play-multi-player-how-to-receive-the-invite-when-the-app-is-closed

Do you have a listener setup to handle invitations:

https://docs.coronalabs.com/plugin/gpgs/multiplayer/invitations/index.html

Rob

Yes, and when I’m inside the app and get an invitation, it works. But when I’m opening the app because of accepting an invitation on Play Games, nothing shows.