game_services_firebase_auth 2.0.0 copy "game_services_firebase_auth: ^2.0.0" to clipboard
game_services_firebase_auth: ^2.0.0 copied to clipboard

A Flutter plugin that simplifies Firebase Authentication using GameCenter on iOS and Play Games on Android.

🎮 Game Services FirebaseAuth Plugin #

A Flutter plugin that simplifies Firebase Authentication using GameCenter on iOS and Play Games on Android.

Features #

  • Cross-Platform Support: Authenticate users via GameCenter (iOS) and Play Games (Android) using Firebase.
  • Simple Integration: Minimal setup to sign in, link accounts, and manage authentication.

Requirements #

  • Firebase Auth

Installation #

To install the plugin, add the following to your pubspec.yaml:

dependencies:
  game_services_firebase_auth: ^latest_version

Then, run the following command to fetch the dependency:

flutter pub get

Carefully follow the setup instructions for both iOS and Android to avoid configuration errors.

🍏 iOS Setup #

  1. Ensure Firebase is properly configured for your iOS project. Follow the Firebase setup guide.
  2. Open your project in Xcode, navigate to the Signing & Capabilities tab, and add the Game Center capability. Learn more.
  3. Enable Game Center authentication in the Firebase Console.

Firebase Activate Game Center

🤖 Android Setup #

Refer to the official documentation for enabling Play Games services.

  1. Make sure Firebase is configured correctly for Android. Setup instructions here.
  2. Retrieve your project’s SHA-1 keys using the command below:
./gradlew signingReport
  1. Add the SHA-1 keys to your Firebase Console, including debug and production keys.

Firebase Android SHA-1

  1. Create a Web OAuth client ID in the Google Cloud Console and save the credentials (ID & secret).
  2. Enable Google Play Games as a sign-in provider in the Firebase Console. Use the OAuth credentials created in the previous step.

Firebase Sign-In Method

  1. For each SHA-1 key (e.g., one for debug and one for Play Console), create a corresponding OAuth Android client ID in Google Cloud Console.

GCP OAuth Keys

  1. Activate Play Games on your app in the Google Play Console and fill in the required fields.
  2. Create Play Services credentials for each key (from step 6).

Google Play Keys

  1. Add the following metadata to your AndroidManifest.xml:
<meta-data
    android:name="com.google.android.gms.games.APP_ID"
    android:value="@string/game_services_project_id" />

<meta-data
    android:name="io.revoltgames.game_services_firebase_auth.OAUTH_2_WEB_CLIENT_ID"
    android:value="@string/game_services_oauth_2_web_client_id" />
  1. In your res/values/strings.xml, add the following values (replace XXXXXX with your actual values):
<resources>
    <string name="game_services_project_id" translatable="false">XXXXXX</string>
    <string name="game_services_oauth_2_web_client_id" translatable="false">XXXXXX</string>
</resources>
  1. Finally, run the Firebase configuration command to ensure everything is set up:
flutterfire configure

Usage #

Sign In with Game Services #

await FirebaseAuth.instance.signInWithGamesServices();

Check if User is Linked with Game Services #

bool isLinked = firebaseUser.isLinkedWithGamesServices();
await firebaseUser.linkWithGamesServices();

Force Sign-In if Account Already Linked #

await firebaseUser.linkWithGamesServices(forceSignInWithGameServiceIfCredentialAlreadyUsed: true);

Troubleshooting #

iOS #

Error: Lexical or Preprocessor Issue (Xcode): Include of non-modular header inside framework module 'firebase_auth.FLTIdTokenChannelStreamHandle'

To resolve this issue:

  1. Open your project in Xcode.
  2. Navigate to Build Settings under your target.
  3. Set Allow Non-modular Includes in Framework Modules to YES.

Contributing #

Contributions are welcome! Please check out the contributing guidelines for more details.

License #

This project is licensed under the BSD-3-Clause License. See the LICENSE file for more information.

11
likes
0
pub points
59%
popularity

Publisher

verified publisherrevoltgames.io

A Flutter plugin that simplifies Firebase Authentication using GameCenter on iOS and Play Games on Android.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

firebase_auth, flutter, logging, plugin_platform_interface

More

Packages that depend on game_services_firebase_auth