feat(google-play-games-services): add getPlayerScore function (#2949)

This commit is contained in:
Arzan Bhorr 2019-04-07 19:13:04 +02:00 committed by Daniel Sogl
parent 39be27566b
commit 767d3b3dd4

View File

@ -15,6 +15,13 @@ export interface ScoreData {
} }
export interface PlayerScoreData {
/**
* The player score.
*/
playerScore: number;
}
export interface LeaderboardData { export interface LeaderboardData {
/** /**
@ -126,6 +133,13 @@ export interface Player {
* leaderboardId: 'SomeLeaderboardId' * leaderboardId: 'SomeLeaderboardId'
* }); * });
* *
* // Get the player score on a leaderboard.
* this.googlePlayGamesServices.getPlayerScore({
* leaderboardId: 'SomeLeaderBoardId'
* }).then((data: PlayerScoreData) => {
* console.log('Player score', data);
* });
*
* // Show the native leaderboards window. * // Show the native leaderboards window.
* this.googlePlayGamesServices.showAllLeaderboards() * this.googlePlayGamesServices.showAllLeaderboards()
* .then(() => console.log('The leaderboard window is visible.')); * .then(() => console.log('The leaderboard window is visible.'));
@ -220,6 +234,19 @@ export class GooglePlayGamesServices extends IonicNativePlugin {
return; return;
} }
/**
* Get the player score on a leaderboard. You should ensure that you have a
* successful return from auth() before requesting a score.
*
* @param data {LeaderboardData} The leaderboard score you want to request.
* @return {Promise<PlayerScoreData>} Returns a promise that resolves when Play
* Games Services returns the player score.
*/
@Cordova()
getPlayerScore(data: LeaderboardData): Promise<PlayerScoreData> {
return;
}
/** /**
* Launches the native Play Games leaderboard view controller to show all the * Launches the native Play Games leaderboard view controller to show all the
* leaderboards. * leaderboards.