Packagecom.distriqt.extension.gameservices
Classpublic final class GameServices
InheritanceGameServices Inheritance flash.events.EventDispatcher

This class represents the main interface to the Game Services extension.

For documentation on using this extension please see the wiki accessible from where you download the extension.



Public Properties
 PropertyDefined By
  accessPoint : AccessPoint
[read-only] Access to the access point functionality.
GameServices
  achievements : Achievements
[read-only] Access to the achievements functionality.
GameServices
  authUtil : AuthUtil
[read-only] AuthUtil provides static utility methods to, Acquire ClientLogin, OAuth2, ID, or offline access tokens for Google accounts. Invalidate ClientLogin or OAuth2 tokens.
GameServices
  implementation : String
[read-only] The implementation currently in use.
GameServices
  isGooglePlayGamesInstalled : Boolean
[read-only] Checks the applications installed on the device to determine if Google Play Games is installed.
GameServices
  isSupported : Boolean
[static] [read-only] Whether the current device supports the extensions functionality
GameServices
  leaderboards : Leaderboards
[read-only] Access to the leaderboard functionality.
GameServices
  nativeVersion : String
[read-only] The native version string of the native extension.
GameServices
  players : Players
[read-only] Access to the Players functionality to load additional information about the current player such as recently played with players and friends.
GameServices
  quests : Quests
[read-only] Access to the quests functionality.
GameServices
  recording : ScreenRecording
[read-only] Access to the screen recording functionality.
GameServices
  savedGames : SavedGames
[read-only] Access to the saved games functionality.
GameServices
  service : GameServices
[static] [read-only] The singleton instance of the GameServices class.
GameServices
  turnBasedMultiplayer : TurnBasedMultiplayer
[read-only] Access to the turn based multiplayer functionality.
GameServices
  version : String
[read-only] The version of this extension.
GameServices
Public Methods
 MethodDefined By
  
Constructor You should not call this directly, but instead use the singleton access
GameServices
  
disconnect():Boolean
Disconnects the current user from the app and revokes previous authentication.
GameServices
  
dispose():void
Disposes the extension and releases any allocated resources.
GameServices
  
Deprecated: Player retrieval is now asynchronous. This will only return the previous asynchronously retrieved value
Gets information about the signed in player
GameServices
  
init(key:String):void
Deprecated: You no longer need to use an application key
[static] Initialises the extension class for use with the provided key.
GameServices
  
initialiseService(service:Service):Boolean
Initialises the extension to use the specified service.
GameServices
  
isServiceSupported(service:String):Boolean
Checks whether the specified service is supported on the current device.
GameServices
  
isSignedIn():Boolean
Checks if the player is currently signed into the initialised service.
GameServices
  
Loads any invites for the current user.
GameServices
  
loadPlayer():Boolean
Retrieves information about the signed in player asynchronously.
GameServices
  
loadPlayerIcon(player:Player):Boolean
Loads any available icon for the specified player Will dispatch either: PlayerIconEvent.LOADED: when successful PlayerIconEvent.ERROR: when an error occurs
GameServices
  
register():Boolean
Registers for notifications from multiplayer game invitations and match updates.
GameServices
  
showUI(state:String = default):Boolean
Shows the game service user interface.
GameServices
  
signIn(silently:Boolean = false):Boolean
Starts the sign in process for the initialised service.
GameServices
  
signOut():Boolean
Signs out a currently signed in user.
GameServices
Events
 Event Summary Defined By
   Dispatched after the requested service has completed initialising.GameServices
   Dispatched when an invitation is received data will be an instance of the Invitation class.GameServices
   data contains a String with the invitationId that was removed.GameServices
   An error occurred, message will contain a description of the error GameServices
   This is dispatched when the current service doesn't support loading of invitations.GameServices
   data contains an array of Invitation objects each representing an current invite.GameServices
   Dispatched when an error occurs when loading the icon error will contain any additional information about the error.GameServices
   Dispatched when a load for a player's icon has completed.GameServices
   GameServices
   GameServices
   GameServices
Public Constants
 ConstantDefined By
  EXT_CONTEXT_ID : String = com.distriqt.GameServices
[static]
GameServices
  VERSION : String = 10.0.0
[static]
GameServices
Property Detail
accessPointproperty
accessPoint:AccessPoint  [read-only]

Access to the access point functionality.


Implementation
    public function get accessPoint():AccessPoint
achievementsproperty 
achievements:Achievements  [read-only]

Access to the achievements functionality.


Implementation
    public function get achievements():Achievements
authUtilproperty 
authUtil:AuthUtil  [read-only]

AuthUtil provides static utility methods to,


Implementation
    public function get authUtil():AuthUtil
implementationproperty 
implementation:String  [read-only]

The implementation currently in use. This should be one of the following depending on the platform in use and the functionality supported by this extension:


Implementation
    public function get implementation():String
isGooglePlayGamesInstalledproperty 
isGooglePlayGamesInstalled:Boolean  [read-only]

Checks the applications installed on the device to determine if Google Play Games is installed. The Play Games app is required for Play Games services, however it is installed as part of the sign in process if it is missing, so this flag can just be used as an information flag for your users. This will always return false if isServiceSupported( Service.GOOGLE_PLAY_GAME_SERVICES ) returns false (i.e on iOS or unsupported Android devices).


Implementation
    public function get isGooglePlayGamesInstalled():Boolean
isSupportedproperty 
isSupported:Boolean  [read-only]

Whether the current device supports the extensions functionality


Implementation
    public static function get isSupported():Boolean
leaderboardsproperty 
leaderboards:Leaderboards  [read-only]

Access to the leaderboard functionality.


Implementation
    public function get leaderboards():Leaderboards

Example

The following starts the load of the leaderboards from the service.

         GameServices.service.leaderboards.addEventListener( LeaderboardEvent.LEADERBOARDS_LOADED, leaderboardsLoadedHandler );
         GameServices.service.leaderboards.addEventListener( LeaderboardEvent.LEADERBOARDS_ERROR,  leaderboardsErrorHandler );
                  if (GameServices.service.isSignedIn())
         {
             GameServices.service.leanderboards.loadLeaderboards();
         }
         
nativeVersionproperty 
nativeVersion:String  [read-only]

The native version string of the native extension.


Implementation
    public function get nativeVersion():String
playersproperty 
players:Players  [read-only]

Access to the Players functionality to load additional information about the current player such as recently played with players and friends.


Implementation
    public function get players():Players
questsproperty 
quests:Quests  [read-only]

Access to the quests functionality.


Implementation
    public function get quests():Quests
recordingproperty 
recording:ScreenRecording  [read-only]

Access to the screen recording functionality.


Implementation
    public function get recording():ScreenRecording
savedGamesproperty 
savedGames:SavedGames  [read-only]

Access to the saved games functionality.


Implementation
    public function get savedGames():SavedGames

Example

The following starts the load of available player saved games.

         GameServices.service.savedGames.addEventListener( SavedGamesEvent.LOADED,     savedGamesLoadedHandler );
         GameServices.service.savedGames.addEventListener( SavedGamesEvent.LOAD_ERROR, savedGamesLoadErrorHandler );
                  if (GameServices.service.isSignedIn())
         {
             GameServices.service.savedGames.loadSavedGames();
         }
         
serviceproperty 
service:GameServices  [read-only]

The singleton instance of the GameServices class.


Implementation
    public static function get service():GameServices

Throws
Error — If there was a problem creating or accessing the extension, or if the key is invalid
turnBasedMultiplayerproperty 
turnBasedMultiplayer:TurnBasedMultiplayer  [read-only]

Access to the turn based multiplayer functionality.


Implementation
    public function get turnBasedMultiplayer():TurnBasedMultiplayer
versionproperty 
version:String  [read-only]

The version of this extension.

This should be of the format, MAJOR.MINOR.BUILD


Implementation
    public function get version():String
Constructor Detail
GameServices()Constructor
public function GameServices()

Constructor You should not call this directly, but instead use the singleton access

Method Detail
disconnect()method
public function disconnect():Boolean

Disconnects the current user from the app and revokes previous authentication. If the operation succeeds, the OAuth 2.0 token is also removed from keychain.

Once disconnect is called you can expect signInSilently to fail.

Game Center does not support this functionality and will return false.

Returns
Boolean — true if started successfully and false otherwise
dispose()method 
public function dispose():void

Disposes the extension and releases any allocated resources. Once this function has been called, a call to init is neccesary again before any of the extensions functionality will work.

getPlayer()method 
public function getPlayer():Player
Deprecated: Player retrieval is now asynchronous. This will only return the previous asynchronously retrieved value

Gets information about the signed in player

Returns
Player — The player/user that is currently signed in, null if an error occurred or there is no player signed in

See also

com.distriqt.extension.gameservices.objects.Player
init()method 
public static function init(key:String):void
Deprecated: You no longer need to use an application key

Initialises the extension class for use with the provided key.

Parameters

key:String


Throws
Error — If there was a problem creating or accessing the extension, or if the key is invalid
initialiseService()method 
public function initialiseService(service:Service):Boolean

Initialises the extension to use the specified service.

Parameters

service:Service — An instance of the Service class specifying the options for the service

Returns
Boolean — true on success and false if the platform isn't supported or if the service has already been initialised

See also

isServiceSupported()method 
public function isServiceSupported(service:String):Boolean

Checks whether the specified service is supported on the current device.

Parameters

service:String — A service definition from the Service class definitions

Returns
Boolean — true if the service is supported on the current device

See also

isSignedIn()method 
public function isSignedIn():Boolean

Checks if the player is currently signed into the initialised service.

Returns
Boolean — true if the player is signed in and false otherwise
loadInvites()method 
public function loadInvites():void

Loads any invites for the current user.

See also

loadPlayer()method 
public function loadPlayer():Boolean

Retrieves information about the signed in player asynchronously.

This replaces the older getPlayer function, as the process is now an asynchronous query to the game services server.

Will dispatch either:

Returns
Booleantrue if the process was started successfully and false if the user isn't signed in or the service isn't setup.

Example
GameServices.service.addEventListener( PlayerEvent.LOADED, loadPlayer_loadedHandler );
GameServices.service.addEventListener( PlayerEvent.ERROR, loadPlayer_errorHandler );
GameServices.service.loadPlayer();

function loadPlayer_loadedHandler( event:PlayerEvent ):void
{
    var player:Player = event.player;
    trace( "player :: "+ "["+player.id+"]" +player.displayName + "(" + player.alias + ")" );
}

function loadPlayer_errorHandler( event:PlayerEvent ):void
{
     trace( "loadPlayer_errorHandler(): " + event.error );
}
         
loadPlayerIcon()method 
public function loadPlayerIcon(player:Player):Boolean

Loads any available icon for the specified player

Will dispatch either:

Parameters

player:Player — The player to retrieve an icon for

Returns
Booleantrue if successful and false otherwise

See also

register()method 
public function register():Boolean

Registers for notifications from multiplayer game invitations and match updates.

Important: This must be called AFTER a player is successfully signed in and you should call it as soon as possible after a successful sign in.

Note: Google Play Android: If this method is called, the incoming invitation will not generate a status bar notification as long as this client remains connected.

Note: iOS This method, on some services, may display the request permissions dialog to ask the user permission to use push notifications.

Returns
Booleantrue if successful and false otherwise
showUI()method 
public function showUI(state:String = default):Boolean

Shows the game service user interface. Will dispatch GameServicesEvent.UI_CLOSED when the ui is closed by the user and focus returned to your application.

Parameters

state:String (default = default) — The particular state / type to display

Returns
Booleantrue if the ui was launched and false if it isn't supported on the current service or if the user is not signed in
signIn()method 
public function signIn(silently:Boolean = false):Boolean

Starts the sign in process for the initialised service. By default this will present a UI if required to the user to allow them to sign in to the specified service.

If silently is specified then the service will attempt not to display any login dialogs to the user. You can use this to attempt a silent login at startup to see if the user can authenticate without interaction. If a SIGN_IN_FAILED is dispatched after this then you should attempt a non-silent login whenever suits your UI.

Parameters

silently:Boolean (default = false) — If the service should attempt a silent login (if available)

Returns
Boolean — true if the sign in process was started and false if the service hasn't been initialised or if the user is already signed in

See also

signOut()method 
public function signOut():Boolean

Signs out a currently signed in user.

Returns
Booleantrue if the user was successfully signed out and false if the user wasn't signed in

See also

Event Detail
initialised Event
Event Object Type: com.distriqt.extension.gameservices.events.GameServicesEvent
GameServicesEvent.type property = com.distriqt.extension.gameservices.events.GameServicesEvent.INITIALISED

Dispatched after the requested service has completed initialising. You should wait for this event after a call to initialiseService.
multiplayer:invitation:received Event  
Event Object Type: com.distriqt.extension.gameservices.events.MultiplayerEvent
MultiplayerEvent.type property = com.distriqt.extension.gameservices.events.MultiplayerEvent.INVITATION_RECEIVED

Dispatched when an invitation is received

data will be an instance of the Invitation class.

multiplayer:invitation:removed Event  
Event Object Type: com.distriqt.extension.gameservices.events.MultiplayerEvent
MultiplayerEvent.type property = com.distriqt.extension.gameservices.events.MultiplayerEvent.INVITATION_REMOVED

data contains a String with the invitationId that was removed.

multiplayer:loadinvites:failed Event  
Event Object Type: com.distriqt.extension.gameservices.events.MultiplayerEvent
MultiplayerEvent.type property = com.distriqt.extension.gameservices.events.MultiplayerEvent.LOADINVITES_FAILED

An error occurred, message will contain a description of the error

multiplayer:loadinvites:notsupported Event  
Event Object Type: com.distriqt.extension.gameservices.events.MultiplayerEvent
MultiplayerEvent.type property = com.distriqt.extension.gameservices.events.MultiplayerEvent.LOADINVITES_NOT_SUPPORTED

This is dispatched when the current service doesn't support loading of invitations. You should treat this as a success and display an alternative interface to your user.

multiplayer:loadinvites:success Event  
Event Object Type: com.distriqt.extension.gameservices.events.MultiplayerEvent
MultiplayerEvent.type property = com.distriqt.extension.gameservices.events.MultiplayerEvent.LOADINVITES_SUCCESS

data contains an array of Invitation objects each representing an current invite.

player:icon:error Event  
Event Object Type: com.distriqt.extension.gameservices.events.PlayerIconEvent
PlayerIconEvent.type property = com.distriqt.extension.gameservices.events.PlayerIconEvent.ERROR

Dispatched when an error occurs when loading the icon error will contain any additional information about the error.

If you are using Play Services on iOS 9+ you may need to check your info additions. You need to make sure you have added the App Transport Security additions required to load data from the Google servers, in particular googleusercontent.com.

player:icon:loaded Event  
Event Object Type: com.distriqt.extension.gameservices.events.PlayerIconEvent
PlayerIconEvent.type property = com.distriqt.extension.gameservices.events.PlayerIconEvent.LOADED

Dispatched when a load for a player's icon has completed. icon will contain the bitmap data for the player icon.

signin:failed Event  
Event Object Type: com.distriqt.extension.gameservices.events.GameServicesEvent
GameServicesEvent.type property = com.distriqt.extension.gameservices.events.GameServicesEvent.SIGN_IN_FAILED

signin:success Event  
Event Object Type: com.distriqt.extension.gameservices.events.GameServicesEvent
GameServicesEvent.type property = com.distriqt.extension.gameservices.events.GameServicesEvent.SIGN_IN_SUCCESS

signout:success Event  
Event Object Type: com.distriqt.extension.gameservices.events.GameServicesEvent
GameServicesEvent.type property = com.distriqt.extension.gameservices.events.GameServicesEvent.SIGN_OUT_SUCCESS

Constant Detail
EXT_CONTEXT_IDConstant
public static const EXT_CONTEXT_ID:String = com.distriqt.GameServices

VERSIONConstant 
public static const VERSION:String = 10.0.0