Package | com.distriqt.extension.gameservices |
Class | public final class GameServices |
Inheritance | GameServices ![]() |
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.
Property | Defined 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 |
Method | Defined 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 | ||
loadInvites():void
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 |
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 |
Constant | Defined By | ||
---|---|---|---|
EXT_CONTEXT_ID : String = com.distriqt.GameServices [static] | GameServices | ||
VERSION : String = 10.0.0 [static] | GameServices |
accessPoint | property |
accessPoint:AccessPoint
[read-only] Access to the access point functionality.
public function get accessPoint():AccessPoint
achievements | property |
achievements:Achievements
[read-only]
Access to the achievements functionality.
public function get achievements():Achievements
authUtil | property |
authUtil:AuthUtil
[read-only]
AuthUtil provides static utility methods to,
public function get authUtil():AuthUtil
implementation | property |
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:
Android
iOS
default
unknown
public function get implementation():String
isGooglePlayGamesInstalled | property |
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).
public function get isGooglePlayGamesInstalled():Boolean
isSupported | property |
isSupported:Boolean
[read-only] Whether the current device supports the extensions functionality
public static function get isSupported():Boolean
leaderboards | property |
leaderboards:Leaderboards
[read-only]
Access to the leaderboard functionality.
public function get leaderboards():Leaderboards
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(); }
nativeVersion | property |
nativeVersion:String
[read-only]
The native version string of the native extension.
public function get nativeVersion():String
players | property |
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.
public function get players():Players
quests | property |
quests:Quests
[read-only]
Access to the quests functionality.
public function get quests():Quests
recording | property |
recording:ScreenRecording
[read-only]
Access to the screen recording functionality.
public function get recording():ScreenRecording
savedGames | property |
savedGames:SavedGames
[read-only]
Access to the saved games functionality.
public function get savedGames():SavedGames
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(); }
service | property |
service:GameServices
[read-only] The singleton instance of the GameServices class.
public static function get service():GameServices
Error — If there was a problem creating or accessing the extension, or if the key is invalid
|
turnBasedMultiplayer | property |
turnBasedMultiplayer:TurnBasedMultiplayer
[read-only]
Access to the turn based multiplayer functionality.
public function get turnBasedMultiplayer():TurnBasedMultiplayer
version | property |
version:String
[read-only]
The version of this extension.
This should be of the format, MAJOR.MINOR.BUILD
public function get version():String
GameServices | () | Constructor |
public function GameServices()
Constructor You should not call this directly, but instead use the singleton access
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.
ReturnsBoolean — 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
Gets information about the signed in player
ReturnsPlayer — The player/user that is currently signed in,
null if an error occurred or there is no player signed in
|
See also
init | () | method |
public static function init(key:String):void
Initialises the extension class for use with the provided key.
Parameters
key:String |
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
|
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
|
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.
ReturnsBoolean — 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:
PlayerEvent.LOADED
: when successfulPlayerEvent.ERROR
: when an error occursBoolean — true if the process was started successfully and
false if the user isn't signed in or the service isn't setup.
|
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:
PlayerIconEvent.LOADED
: when successfulPlayerIconEvent.ERROR
: when an error occursParameters
player:Player — The player to retrieve an icon for
|
Boolean — true 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.
ReturnsBoolean — true 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
|
Boolean — true 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)
|
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.
ReturnsBoolean — true if the user was successfully signed out and false if the user wasn't signed in
|
See also
initialised | Event |
com.distriqt.extension.gameservices.events.GameServicesEvent
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 |
com.distriqt.extension.gameservices.events.MultiplayerEvent
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 |
com.distriqt.extension.gameservices.events.MultiplayerEvent
com.distriqt.extension.gameservices.events.MultiplayerEvent.INVITATION_REMOVED
data
contains a String with the invitationId that was removed.
multiplayer:loadinvites:failed | Event |
com.distriqt.extension.gameservices.events.MultiplayerEvent
com.distriqt.extension.gameservices.events.MultiplayerEvent.LOADINVITES_FAILED
An error occurred, message
will contain a description of the error
multiplayer:loadinvites:notsupported | Event |
com.distriqt.extension.gameservices.events.MultiplayerEvent
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 |
com.distriqt.extension.gameservices.events.MultiplayerEvent
com.distriqt.extension.gameservices.events.MultiplayerEvent.LOADINVITES_SUCCESS
data
contains an array of Invitation
objects
each representing an current invite.
player:icon:error | Event |
com.distriqt.extension.gameservices.events.PlayerIconEvent
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 |
com.distriqt.extension.gameservices.events.PlayerIconEvent
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 |
com.distriqt.extension.gameservices.events.GameServicesEvent
com.distriqt.extension.gameservices.events.GameServicesEvent.SIGN_IN_FAILED
signin:success | Event |
com.distriqt.extension.gameservices.events.GameServicesEvent
com.distriqt.extension.gameservices.events.GameServicesEvent.SIGN_IN_SUCCESS
signout:success | Event |
com.distriqt.extension.gameservices.events.GameServicesEvent
com.distriqt.extension.gameservices.events.GameServicesEvent.SIGN_OUT_SUCCESS
EXT_CONTEXT_ID | Constant |
public static const EXT_CONTEXT_ID:String = com.distriqt.GameServices
VERSION | Constant |
public static const VERSION:String = 10.0.0