Skip to content

Commit

Permalink
feat(google-play-games-services): add new synchronous methods (#3138)
Browse files Browse the repository at this point in the history
  • Loading branch information
artberri authored and danielsogl committed Aug 30, 2019
1 parent 64ca73e commit 189570d
Showing 1 changed file with 94 additions and 3 deletions.
97 changes: 94 additions & 3 deletions src/@ionic-native/plugins/google-play-games-services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,40 @@ export interface Player {

}

export interface SubmittedScoreData {

/**
* The leaderboard ID from Goole Play Developer console.
*/
leaderboardId: string;

/**
* The player ID from Goole Play Developer console.
*/
playerId: string;

/**
* The score data in a display-appropriate format.
*/
formattedScore: string;

/**
* Whether or not this score was the player's new best score.
*/
newBest: boolean;

/**
* The raw score value of this score result.
*/
rawScore: number;

/**
* The score tag associated with this result, if any.
*/
scoreTag: string;

}

/**
* @name Google Play Games Services
* @description
Expand Down Expand Up @@ -133,11 +167,19 @@ export interface Player {
* leaderboardId: 'SomeLeaderboardId'
* });
*
* // Submit a score and wait for reponse.
* this.googlePlayGamesServices.submitScoreNow({
* score: 100,
* leaderboardId: 'SomeLeaderboardId'
* }).then((data: SubmittedScoreData) => {
* console.log('Score related data', data);
* });
*
* // Get the player score on a leaderboard.
* this.googlePlayGamesServices.getPlayerScore({
* leaderboardId: 'SomeLeaderBoardId'
* }).then((data: PlayerScoreData) => {
* console.log('Player score', data);
* console.log('Player score', data);
* });
*
* // Show the native leaderboards window.
Expand All @@ -152,12 +194,23 @@ export interface Player {
* // Unlock an achievement.
* this.googlePlayGamesServices.unlockAchievement({
* achievementId: 'SomeAchievementId'
* }).then(() => console.log('Achievement sent'));
*
* // Unlock an achievement and wait for response.
* this.googlePlayGamesServices.unlockAchievementNow({
* achievementId: 'SomeAchievementId'
* }).then(() => console.log('Achievement unlocked'));
*
* // Incremement an achievement.
* this.googlePlayGamesServices.incrementAchievement({
* step: 1,
* achievementId: 'SomeAchievementId'
* }).then(() => console.log('Achievement increment sent'));
*
* // Incremement an achievement and wait for response.
* this.googlePlayGamesServices.incrementAchievementNow({
* step: 1,
* achievementId: 'SomeAchievementId'
* }).then(() => console.log('Achievement incremented'));
*
* // Show the native achievements window.
Expand Down Expand Up @@ -234,6 +287,20 @@ export class GooglePlayGamesServices extends IonicNativePlugin {
return;
}

/**
* Submit a score to a leaderboard and waits for the response from
* Google Play Games. You should ensure that you have a
* successful return from auth() before submitting a score.
*
* @param data {ScoreData} The score data you want to submit.
* @return {Promise<SubmittedScoreData>} Returns a promise that resolves when Play
* Games Services returns the score information.
*/
@Cordova()
submitScoreNow(data: ScoreData): Promise<SubmittedScoreData> {
return;
}

/**
* Get the player score on a leaderboard. You should ensure that you have a
* successful return from auth() before requesting a score.
Expand Down Expand Up @@ -277,25 +344,49 @@ export class GooglePlayGamesServices extends IonicNativePlugin {
*
* @param data {AchievementData}
* @return {Promise<any>} Returns a promise that resolves when the
* achievement is unlocked.
* achievement is sent.
*/
@Cordova()
unlockAchievement(data: AchievementData): Promise<string> {
return;
}

/**
* Unlock an achievement and wait for response.
*
* @param data {AchievementData}
* @return {Promise<any>} Returns a promise that resolves when the Play
* Games Services returns that the achievement is unlocked.
*/
@Cordova()
unlockAchievementNow(data: AchievementData): Promise<string> {
return;
}

/**
* Increment an achievement.
*
* @param data {IncrementableAchievementData}
* @return {Promise<any>} Returns a promise that resolves when the
* achievement is incremented.
* achievement is sent.
*/
@Cordova()
incrementAchievement(data: IncrementableAchievementData): Promise<string> {
return;
}

/**
* Increment an achievement and wait for response.
*
* @param data {IncrementableAchievementData}
* @return {Promise<any>} Returns a promise that resolves when the Play
* Games Services returns that the achievement has been incremented.
*/
@Cordova()
incrementAchievementNow(data: IncrementableAchievementData): Promise<string> {
return;
}

/**
* Lauches the native Play Games achievements view controller to show
* achievements.
Expand Down

0 comments on commit 189570d

Please sign in to comment.