games services
a flutter plugin to support game center and google play games services.
screenshot for some games services
ios
android
usage
sign in:
to sign in the user. you need to call the sign in before
making any action (like sending a score or unlocking an achievement).
gamesservices.signin();
show achievements:
to show the achievements screen.
gamesservices.showachievements();
show leaderboards:
to show the leaderboards screen.
gamesservices.showleaderboards(iosleaderboardid: 'ios_leaderboard_id');
note: you need to pass the leaderboard id for ios, for android it’s not required.
submit score:
to submit a score
to specific leader board.
-the score
class takes three parameters:
–androidleaderboardid
: the leader board id that you want to send the score for in case of android.
–iosleaderboardid
the leader board id that you want to send the score for in case of ios.
–value
the score.
gamesservices.submitscore(score: score(androidleaderboardid: 'android_leaderboard_id',
iosleaderboardid: 'ios_leaderboard_id',
value: 5));
note: you need to pass the leaderboard id for ios in case of ios and the leaderboard id for android in case of android.
unlock achievement:
to unlock an achievement
.
the achievement
takes three parameters:
–androidid
the achievement id for android.
–iosid
the achievement id for ios.
–percentcomplete
the completion percent of the achievement, this parameter is optional in case of ios.
gamesservices.unlock(achievement: achievement(androidid: 'android_id',
iosid: 'ios_id',
percentcomplete: 100));
note: you need to pass the achievement id for ios in case of ios and the achievement id for android in case of android.
the percentcomplete
is required in case of ios but not android.
installing
simply add the following line to your pubspec.yaml file:
dependencies:
games_services: any # <-- add this line
Comments are closed.