Firebase Game Services
A Flutter package, linking Google's Play Games and Apple's Game Center with Firebase.
Setup
iOS Setup
Android Setup
Usage
Sign in
Call this before making any other action.
await FirebaseGameServices.signIn();
Sign in linked user
Signs in the currently linked user with native Game Service (Play Games on Android and GameCenter on iOS) to Firebase.
await FirebaseGameServices.signInLinkedUser();
Sign out
Signs out the user.
await FirebaseAuth.instance.signOut();
Save
This package works in harmony with the Firebase stack.
You can utilize both Cloud Firestore and/or Realtime Database for storing, syncing, and querying data, whatever suits your project best.
For static storage, I'd recommend using Cloud Storage.
Of course you can also use your own backend.
Show leaderboards
To show the leaderboards screen. It takes the leaderbord id for android and iOS.
await FirebaseGameServices.showLeaderboards(iOSLeaderboardID: 'ios_leaderboard_id', androidLeaderboardID: 'android_leaderboard_id');
Submit score
To submit a Score to specific leaderboard.
-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.
await suFirebaseGameServices.submitScore(
score: Score(
androidLeaderboardID: 'android_leaderboard_id',
iOSLeaderboardID: 'ios_leaderboard_id',
value: 5,
)
);
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.
-steps the achievement steps for Android.
await FirebaseGameServices.unlock(
achievement: Achievement(
androidID: 'android_id', iOSID: 'ios_id',
percentComplete: 100, steps: 2
),
);
Increment (Android Only)
To increment the steps for android achievement.
await FirebaseGameServices.increment(achievement: Achievement(androidID: 'android_id', steps: 50));
Show AccessPoint (iOS Only)
To show the access point you can call the following function:
await FirebaseGameServices.showAccessPoint(AccessPointLocation.topLeading);
This feature support only on the iOS, on Android there is nothing like this supported natively.
Hide AccessPoint (iOS Only)
To hide the access point.
await FirebaseGameServices.hideAccessPoint();
Player id
To get the player you can call:
final playerID = FirebaseGameServices.getPlayerID();