0.0.1 • Published 5 months ago

ra-google-play-service v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

ra-google-play-service

Expose Google Play Game Service API

Install

npm install ra-google-play-service
npx cap sync

API

signIn()

signIn() => Promise<SignInResult>

Sign in the user to Google Play Games Services

Returns: Promise<SignInResult>


signOut()

signOut() => Promise<void>

Sign out the user from Google Play Games Services


isSignedIn()

isSignedIn() => Promise<{ isSignedIn: boolean; }>

Check if user is signed in to Google Play Games Services

Returns: Promise<{ isSignedIn: boolean; }>


getPlayerInfo()

getPlayerInfo() => Promise<PlayerInfo>

Get the currently signed in player information

Returns: Promise<PlayerInfo>


showLeaderboard(...)

showLeaderboard(options: LeaderboardOptions) => Promise<void>

Show the leaderboard UI for a specific leaderboard

ParamTypeDescription
optionsLeaderboardOptionsOptions containing leaderboard ID

showAllLeaderboards()

showAllLeaderboards() => Promise<void>

Show all leaderboards UI


submitScore(...)

submitScore(options: SubmitScoreOptions) => Promise<void>

Submit a score to a leaderboard

ParamTypeDescription
optionsSubmitScoreOptionsOptions containing leaderboard ID and score

showAchievements()

showAchievements() => Promise<void>

Show the achievements UI


unlockAchievement(...)

unlockAchievement(options: AchievementOptions) => Promise<void>

Unlock an achievement

ParamTypeDescription
optionsAchievementOptionsOptions containing achievement ID

incrementAchievement(...)

incrementAchievement(options: IncrementAchievementOptions) => Promise<void>

Increment an achievement with the specified amount

ParamTypeDescription
optionsIncrementAchievementOptionsOptions containing achievement ID and increment amount

revealAchievement(...)

revealAchievement(options: AchievementOptions) => Promise<void>

Reveal a hidden achievement

ParamTypeDescription
optionsAchievementOptionsOptions containing achievement ID

saveGameData(...)

saveGameData(options: SaveGameOptions) => Promise<SaveResult>

Save game data to the cloud

ParamTypeDescription
optionsSaveGameOptionsOptions containing save data and description

Returns: Promise<SaveResult>


loadGameData(...)

loadGameData(options: LoadGameOptions) => Promise<LoadGameResult>

Load saved game data from the cloud

ParamTypeDescription
optionsLoadGameOptionsOptions for loading saved game

Returns: Promise<LoadGameResult>


showSavedGames(...)

showSavedGames(options: ShowSavedGamesOptions) => Promise<LoadGameResult>

Show the saved games UI

ParamTypeDescription
optionsShowSavedGamesOptionsOptions for showing saved games UI

Returns: Promise<LoadGameResult>


addListener('signInStatusChanged', ...)

addListener(eventName: 'signInStatusChanged', listenerFunc: (result: SignInResult) => void) => Promise<PluginListenerHandle>

Add listener for sign-in state changes

ParamTypeDescription
eventName'signInStatusChanged'Event to listen for
listenerFunc(result: SignInResult) => voidCallback function

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin


Interfaces

SignInResult

PropTypeDescription
isSignedInbooleanWhether the user is signed in
playerIdstringPlayer ID if signed in
displayNamestringPlayer display name if signed in
imageUrlstringURL to the player's profile image if signed in
errorstringError message if sign in failed

PlayerInfo

PropTypeDescription
playerIdstringPlayer ID
displayNamestringPlayer display name
imageUrlstringURL to the player's profile image

LeaderboardOptions

PropTypeDescription
leaderboardIdstringLeaderboard ID as defined in Google Play Console

SubmitScoreOptions

PropTypeDescription
scorenumberScore to submit to the leaderboard

AchievementOptions

PropTypeDescription
achievementIdstringAchievement ID as defined in Google Play Console

IncrementAchievementOptions

PropTypeDescription
stepsnumberAmount to increment the achievement by

SaveResult

PropTypeDescription
successbooleanWhether save was successful
saveIdstringSave ID of the saved game
errorstringError message if save failed

SaveGameOptions

PropTypeDescription
saveIdstringUnique identifier for the save
datastringSave data as string (will be encoded as needed)
descriptionstringHuman readable description of the save

LoadGameResult

PropTypeDescription
successbooleanWhether data was successfully loaded
saveIdstringSave ID that was loaded
datastringThe loaded save data
descriptionstringDescription of the save
lastModifiedTimestampnumberLast modified timestamp
errorstringError message if load failed

LoadGameOptions

PropTypeDescription
saveIdstringUnique identifier for the save to load

ShowSavedGamesOptions

PropTypeDescription
titlestringTitle to show in the saved games UI
allowAddButtonbooleanWhether to allow creating new saves
allowDeletebooleanWhether to allow deleting saves
maxSavedGamesnumberMaximum number of saves to show

PluginListenerHandle

PropType
remove() => Promise<void>
0.0.1

5 months ago