firebase_game_services 1.0.2 copy "firebase_game_services: ^1.0.2" to clipboard
firebase_game_services: ^1.0.2 copied to clipboard

discontinued

A Flutter package, linking Google's Play Games and Apple's Game Center with Firebase.

Firebase Game Services #

Pub

A Dart package, linking Google's Play Games and Apple's Game Center with Firebase.

Setup #

iOS Setup

  1. Firebase iOS Setup.
  2. Authenticate Using Game Center.

Android Setup

  1. Firebase Android Setup.
  2. Authenticate Using Google Play Games Services on Android.

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 Game Data to Firebase

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.

Save Game Data to iCloud and Google Drive

Even though it is recommended to save game data to firebase, you can also utilize the players iCloud or Google Drive.

Save Game

Takes two parameters: data and a unique name.

final data = jsonEncode(GameData(96, "sword").toJson());
final result = await FirebaseGameServices.saveGame(data: data, name: "foo");

The name must be between 1 and 100 non-URL-reserved characters (a-z, A-Z, 0-9, or the symbols "-", ".", "_", or "~").

Load game

Takes one parameter: name.

final result = await FirebaseGameServices.loadGame(name: "foo");
if (result != null) {
  final Map json = jsonDecode(result);
  final gameData = GameData.fromJson(json);
}
Delete game

Takes one parameter: name.

final result = await FirebaseGameServices.deleteGame(name: "foo");
Get saved games

To get all saved games.

final result = await FirebaseGameServices.getSavedGames();

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 FirebaseGameServices.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();
13
likes
0
pub points
44%
popularity

Publisher

unverified uploader

A Flutter package, linking Google's Play Games and Apple's Game Center with Firebase.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

firebase_game_services_apple, firebase_game_services_google, firebase_game_services_platform_interface, flutter

More

Packages that depend on firebase_game_services