Google Play Games Services

Type Library
Revision Release 2024.3703
Keywords google, google play games services, achievements, leaderboards
Platforms Android
Sample GitHub

Overview

This plugin enables access to Google Play Games Services API, such as achievements, leaderboards and snapshots(Saved Games).

Make sure you check out Google's Setup Guide to get before getting started with the plugin.

If you encounter Google Play Games Services login issues/errors after implementing this plugin, ensure that you have enabled Google Play Developer API within the Google Play Developer Console.

Also, in order to use snapshots you must add Drive API within the Google Play Developer Console.

Important

If you deploy the application locally using Copy to device, Google Play Games Services will not work. You must use Google Play's testing tracks(internal, closed or open testing) to deploy your application.

Changes from GPGS V2 to V3

Changed Apis

gpgs.init()

Initialize is now required and will attempt to sign in the player automatically

gpgs.isConnected(listener)

isConnected is now async and has a callback. use isConnected to check if a player is automatically connected via init or manually login functions

gpgs.isAuthenticated()

isAuthenticated is actually the same but should be noted that isAuthenticated only applies for logins in via gpgs.login(). This is important for Snapshots which is needed to use gpgs.login() for requesting Drive API access.

gpgs.login()

There is a new useDrive param which is need for Snapshots. It is import to note that the Drive scope is not added by default and you must set the useDrive param to true.

No longer supported functions

gpgs.setPopupPosition()

gpgs.showSettings()

gpgs.loadGame()

gpgs.clearNotifications()

gpgs.videos.*

Revert back to gpgs.v2 to use these functions

Syntax

local gpgs= require( "plugin.gpgs.v3" )

Project Settings

To use this plugin, add an entry into the plugins table of build.settings. When added, the build server will integrate the plugin during the build phase.

settings = {

    plugins =
    {
        ["plugin.gpgs.v3"] =
        {
            publisherId = "com.solar2d",
        },
    },
}

Additionally, you must specify the Google Play Games App ID in the android table of build.settings as the googlePlayGamesAppId key:

settings = {

    android =
    {
        googlePlayGamesAppId = "YOUR_APPLICATION_ID",
    },
}

Nodes

The plugin is divided into API nodes for better organization.

gpgs.*

Overview

This is the base API node for the plugin. It manages connection to the Google's servers, authentication and general SDK tasks.

Functions

Events

Types

Game