gpgs.* — Google Play Games Services

Type Library
Revision 2017.3060
Keywords Google Play Games Services, game network, gpgs
Platforms Android, iOS

Overview

The Google Play Games Services plugin enables access to Google Play Games Services for game networking, including achievements, leaderboards, multiplayer, quests, videos, and more.

Important
  • This plugin is backward-compatible with the legacy gameNetwork.google plugin. To use it, however, you must require() "plugin.gpgs". In addition, you must specify your googlePlayGamesAppId within the android table. Please see Project Settings below for details.

  • If you want to upgrade to this new plugin, you should remove the legacy plugin from build.settings. Although this new plugin is backward-compatible with the legacy API calls, you can not include both plugins inside your build.settings file.

  • To use this plugin, you must implement Google app licensing as outlined here and sign the .apk with a private key as outlined here.

  • Some features/aspects are only available on Android — these will be specified per-feature within this documentation. If no exception is noted, both Android and iOS are supported.

Notes
  • This plugin is currently in beta. APIs and project configuration are subject to change without notice during this time.

  • This plugin is currently available for Android and iOS, but multiplayer for iOS is still in development.

Syntax

local gpgs = require( "plugin.gpgs" )

Functions

These core functions manage connection to Google's servers, authentication, and other tasks.

Nodes

Specific functionality aspects of this plugin are divided into nodes for better organization:

Events

Types

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"] =
        {
            publisherId = "com.coronalabs"
        },
    },
}

Android

If your app is for Android, you must also specify the Google Play Games App ID in the android table of build.settings as the googlePlayGamesAppId key:

settings = {

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

iOS

If your app is for iOS, you must also include various details within build.settings to ensure that Google Play Games Services functions properly:

settings = {

    iphone =
    {
        plist =
        {
            GooglePlayGamesOAuth2ClientId = "YOUR_OAUTH2_CLIENT_ID",
            CFBundleURLTypes =
            {
                { CFBundleURLSchemes = { "YOUR_OAUTH2_CLIENT_ID_REVERSED" } },
                { CFBundleURLSchemes = { "YOUR_IOS_APP_BUNDLE_ID" } },
            },
        }
    },
}

Notice that there are several critical parts which must be specified:

  • GooglePlayGamesOAuth2ClientId — This key's value should be set to the OAuth2 Client ID from Google Play.
  • CFBundleURLTypes — The CFBundleURLTypes table should include two URL scheme tables, as follows:

    The first of these should contain the reverse-domain format of your GooglePlayGamesOAuth2ClientId value — for example, if your GooglePlayGamesOAuth2ClientId is 760035641580-8eho8p557gtaaa7alouh5a2qlhtruomq.apps.googleusercontent.com, this value should be com.googleusercontent.apps.760035641580-8eho8p557gtaaa7alouh5a2qlhtruomq.

    The second of these should contain the Bundle ID of your iOS app as gathered from the Apple Developer portal, for example com.domainname.myapp.

Support