gameNetwork.init()

Type Function
Library gameNetwork.*
Return value none
Revision Release 2024.3703
Keywords gameNetwork, Google Play Game Services
See also gameNetwork.request()
gameNetwork.show()

Overview

Initializes an app for use with Google Play Game Services.

Syntax

gameNetwork.init( "google" [, initCallback] )
initCallback (optional)

Listener. Callback function where, upon successful initialization, event.isError will be nil. On unsuccessful initialization, event.isError will be true. When problems such as network errors occur, event.errorCode (integer) and event.errorMessage (string) will be defined.

Example

local gameNetwork = require( "gameNetwork" )

local function initCallback( event )
    if not event.isError then
        native.showAlert( "Success!", "", { "OK" } )
    else
        native.showAlert( "Failed!", event.errorMessage, { "OK" } )
        print( "Error Code:", event.errorCode )
    end
end

local function onSystemEvent( event )
    if ( event.type == "applicationStart" ) then
        gameNetwork.init( "google", initCallback )
        return true
    end
end
Runtime:addEventListener( "system", onSystemEvent )