import { GooglePlayGamesServices } from '@ionic-native/google-play-games-services/ngx';
constructor(private googlePlayGamesServices: GooglePlayGamesServices) { }
...
this.googlePlayGamesServices.auth()
.then(() => console.log('Logged in to Play Games Services'))
.catch(e) => console.log('Error logging in Play Games Services', e);
this.googlePlayGamesServices.signOut()
.then(() => console.log('Logged out of Play Games Services'))
.catch(e => console.log('Error logging out of Play Games Services', e);
this.googlePlayGamesServices.isSignedIn()
.then((signedIn: SignedInResponse) => {
if (signedIn.isSignedIn) {
hideLoginButton();
}
});
this.googlePlayGamesServices.showPlayer().then((data: Player) => {
console.log('Player data', data);
});
this.googlePlayGamesServices.submitScore({
score: 100,
leaderboardId: 'SomeLeaderboardId'
});
this.googlePlayGamesServices.submitScoreNow({
score: 100,
leaderboardId: 'SomeLeaderboardId'
}).then((data: SubmittedScoreData) => {
console.log('Score related data', data);
});
this.googlePlayGamesServices.getPlayerScore({
leaderboardId: 'SomeLeaderBoardId'
}).then((data: PlayerScoreData) => {
console.log('Player score', data);
});
this.googlePlayGamesServices.showAllLeaderboards()
.then(() => console.log('The leaderboard window is visible.'));
this.googlePlayGamesServices.showLeaderboard({
leaderboardId: 'SomeLeaderBoardId'
}).then(() => console.log('The leaderboard window is visible.'));
this.googlePlayGamesServices.unlockAchievement({
achievementId: 'SomeAchievementId'
}).then(() => console.log('Achievement sent'));
this.googlePlayGamesServices.unlockAchievementNow({
achievementId: 'SomeAchievementId'
}).then(() => console.log('Achievement unlocked'));
this.googlePlayGamesServices.incrementAchievement({
step: 1,
achievementId: 'SomeAchievementId'
}).then(() => console.log('Achievement increment sent'));
this.googlePlayGamesServices.incrementAchievementNow({
step: 1,
achievementId: 'SomeAchievementId'
}).then(() => console.log('Achievement incremented'));
this.googlePlayGamesServices.showAchivements()
.then(() => console.log('The achievements window is visible.'));