-
Notifications
You must be signed in to change notification settings - Fork 4
General
Play Games Services sign-in provides you with a player's gaming identity, which is a platform-level, gaming-specific identity for Android players. This identity helps build a relationship between your game and the player. Players are more willing to use this identity to sign in than with alternate centralized systems.
The following functions are provided for general tasks:
- GooglePlayServices_IsAuthenticated
- GooglePlayServices_IsAvailable
- GooglePlayServices_RequestServerSideAccess
- GooglePlayServices_SignIn
The following structures are provided as response for some GooglePlayServices API calls:
Queries the servers for the current authentication status.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GooglePlayServices_IsAuthenticated()
Returns:
Triggers:
Key | Type | Description |
---|---|---|
type | String | The string "GooglePlayServices_IsAuthenticated"
|
success | Boolean | Whether or not the function request succeeded |
isAuthenticated | Boolean | Whether or not player is authenticated |
Example:
GooglePlayServices_IsAuthenticated()
The code sample above save the identifier that can be used inside an Social Async Event.
if(async_load[? "type"] == "GooglePlayServices_IsAuthenticated")
{
if(!async_load[?"success"])
exit
if(async_load[?"isAuthenticated"]);
{
show_debug_message("GoolePlayServices Player Authenticated")
}
else
{
GooglePlayServices_SignIn()
}
}
The code above matches the response against the correct event type and, if the player is not authenticated yet, it calls GooglePlayServices_SignIn to initiate the sign in process.
This function returns whether or not the user has GooglePlayServices installed into their devices. This is required for using any of the extension functions.
Syntax:
GooglePlayServices_IsAvailable()
Returns:
Example:
if(GooglePlayServices_IsAvailable())
{
show_debug_message("GooglePlayServices Available")
//Do something
}
The code sample above will check if the GooglePlayServices are installed into the device after a positive result from this call you can call any of the function from the extension.
Requests server-side access to Play Games Services for the currently signed-in player, this is necessary for 3rd party apps that need GooglePlayServices authentication.
When requested, an authorization code is returned that can be used by your server to exchange for an access token (and conditionally a refresh token when forceRefreshToken
is true
). The access token may then be used by your server to access the Play Games Services web APIs. This is commonly used to complete a sign-in flow by verifying the Play Games Services player ID.
If forceRefreshToken
is true
, when exchanging the authorization code, a refresh token will be returned in addition to the access token. The refresh token allows your server to request additional access tokens, allowing your server to continue accesses Play Games Services while the user is not actively playing your game. Refresh tokens are only generated for players that have auto sign-in setting enabled.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GooglePlayServices_RequestServerSideAccess(serverClientId, forceRefreshToken)
Argument | Type | Description |
---|---|---|
serverClientId | String | The client ID of the server that will perform the authorization code flow exchange. |
forceRefreshToken | Boolean | If true , when the returned authorization code is exchanged, a refresh token will be included in addition to an access token. |
Returns:
Triggers:
Key | Type | Description |
---|---|---|
type | String | The string "GooglePlayServices_RequestServerSideAccess"
|
success | Boolean | Whether or not the function request succeeded. |
authCode | String | The authorization code |
Example:
GooglePlayServices_RequestServerSideAccess()
The code sample above requests for an authorization code that will allow server side access, the code can be caught inside an Social Async Event.
if(async_load[? "type"] == "GooglePlayServices_RequestServerSideAccess")
{
if(!async_load[?"success"])
exit
var authorizationCode = async_load[?"authCode"];
// Use the code to request a accessToken (with optional refreshToken)
}
The code above matches the response against the correct event type and in case of success caches the authorization code that can be later used on 3rd party libraries.
Manually requests that your game sign in with Play Games Services.
Note
A sign-in attempt will be made automatically when your game starts. Games will only need to manually request to sign in if the automatic sign-in attempt failed.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GooglePlayServices_SignIn()
Returns:
Triggers:
Key | Type | Description |
---|---|---|
type | String | The string "GooglePlayServices_SignIn"
|
success | Boolean | Whether or not the function request succeeded |
isAuthenticated | Boolean | Whether or not player is authenticated |
Example:
GooglePlayServices_SignIn()
The code sample above save the identifier that can be used inside an Social Async Event.
if(async_load[? "type"] == "GooglePlayServices_SignIn")
{
if(!async_load[?"success"])
exit
if(async_load[?"isAuthenticated"]);
{
show_debug_message("GoolePlayServices Player Authenticated")
}
else
{
show_debug_message("Lets continue without GooglePlayGameServices")
}
}
The code above matches the response against the correct event type and logs the success of the task.
This is the GameJSON is a json formatted string representing a game and its associated metadata.
This struct is referenced by the following structs:
Member | Type | Description |
---|---|---|
areSnapshotsEnabled | Boolean | Whether or not this game supports snapshots. |
achievementTotalCount | Real | The number of achievements registered for this game. |
applicationId | String | The application ID for this game. |
description | String | The description of this game. |
developerName | String | The name of the developer of this game. |
displayName | String | The display name for this game. |
featuredImageUri | String | An image URI that can be used to load the game's featured (banner) image from Google Play (see GooglePlayServices_UriToPath). Not present if the game has no featured image. |
hiResImageUri | String | An image URI that can be used to load the game's hi-res image (see GooglePlayServices_UriToPath). Not present if the game has no high-res image. |
iconImageUri | String | An image URI that can be used to load the game's icon (see GooglePlayServices_UriToPath). Not present if the game has no icon image. |
leaderboardCount | Real | The number of leaderboards registered for this game. |
primaryCategory | String | The primary category of the game. |
secondaryCategory | String | The secondary category of the game. |
themeColor | String | The theme color for this game. |
gamepadSupport | Boolean | Whether or not this game is marked as supporting gamepads. |
GameMaker 2024