mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-31 18:49:43 +08:00
feat(google-play-games-services): add new synchronous methods (#3138)
This commit is contained in:
parent
64ca73e5cc
commit
189570d255
@ -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
|
* @name Google Play Games Services
|
||||||
* @description
|
* @description
|
||||||
@ -133,6 +167,14 @@ export interface Player {
|
|||||||
* leaderboardId: 'SomeLeaderboardId'
|
* 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.
|
* // Get the player score on a leaderboard.
|
||||||
* this.googlePlayGamesServices.getPlayerScore({
|
* this.googlePlayGamesServices.getPlayerScore({
|
||||||
* leaderboardId: 'SomeLeaderBoardId'
|
* leaderboardId: 'SomeLeaderBoardId'
|
||||||
@ -152,12 +194,23 @@ export interface Player {
|
|||||||
* // Unlock an achievement.
|
* // Unlock an achievement.
|
||||||
* this.googlePlayGamesServices.unlockAchievement({
|
* this.googlePlayGamesServices.unlockAchievement({
|
||||||
* achievementId: 'SomeAchievementId'
|
* achievementId: 'SomeAchievementId'
|
||||||
|
* }).then(() => console.log('Achievement sent'));
|
||||||
|
*
|
||||||
|
* // Unlock an achievement and wait for response.
|
||||||
|
* this.googlePlayGamesServices.unlockAchievementNow({
|
||||||
|
* achievementId: 'SomeAchievementId'
|
||||||
* }).then(() => console.log('Achievement unlocked'));
|
* }).then(() => console.log('Achievement unlocked'));
|
||||||
*
|
*
|
||||||
* // Incremement an achievement.
|
* // Incremement an achievement.
|
||||||
* this.googlePlayGamesServices.incrementAchievement({
|
* this.googlePlayGamesServices.incrementAchievement({
|
||||||
* step: 1,
|
* step: 1,
|
||||||
* achievementId: 'SomeAchievementId'
|
* 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'));
|
* }).then(() => console.log('Achievement incremented'));
|
||||||
*
|
*
|
||||||
* // Show the native achievements window.
|
* // Show the native achievements window.
|
||||||
@ -234,6 +287,20 @@ export class GooglePlayGamesServices extends IonicNativePlugin {
|
|||||||
return;
|
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
|
* Get the player score on a leaderboard. You should ensure that you have a
|
||||||
* successful return from auth() before requesting a score.
|
* successful return from auth() before requesting a score.
|
||||||
@ -277,25 +344,49 @@ export class GooglePlayGamesServices extends IonicNativePlugin {
|
|||||||
*
|
*
|
||||||
* @param data {AchievementData}
|
* @param data {AchievementData}
|
||||||
* @return {Promise<any>} Returns a promise that resolves when the
|
* @return {Promise<any>} Returns a promise that resolves when the
|
||||||
* achievement is unlocked.
|
* achievement is sent.
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
unlockAchievement(data: AchievementData): Promise<string> {
|
unlockAchievement(data: AchievementData): Promise<string> {
|
||||||
return;
|
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.
|
* Increment an achievement.
|
||||||
*
|
*
|
||||||
* @param data {IncrementableAchievementData}
|
* @param data {IncrementableAchievementData}
|
||||||
* @return {Promise<any>} Returns a promise that resolves when the
|
* @return {Promise<any>} Returns a promise that resolves when the
|
||||||
* achievement is incremented.
|
* achievement is sent.
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
incrementAchievement(data: IncrementableAchievementData): Promise<string> {
|
incrementAchievement(data: IncrementableAchievementData): Promise<string> {
|
||||||
return;
|
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
|
* Lauches the native Play Games achievements view controller to show
|
||||||
* achievements.
|
* achievements.
|
||||||
|
Loading…
Reference in New Issue
Block a user