game_services_firebase_auth 2.0.3
game_services_firebase_auth: ^2.0.3 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 #
- Ensure Firebase is properly configured for your iOS project. Follow the Firebase setup guide.
- Open your project in Xcode, navigate to the Signing & Capabilities tab, and add the Game Center capability. Learn more.
- Enable Game Center authentication in the Firebase Console.
🤖 Android Setup #
Refer to the official documentation for enabling Play Games services.
- Make sure Firebase is configured correctly for Android. Setup instructions here.
- Retrieve your project’s SHA-1 keys using the command below:
./gradlew signingReport
- Add the SHA-1 keys to your Firebase Console, including debug and production keys.
- Create a Web OAuth client ID in the Google Cloud Console and save the credentials (ID & secret).
- Enable Google Play Games as a sign-in provider in the Firebase Console. Use the OAuth credentials created in the previous step.
- 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.
- Activate Play Games on your app in the Google Play Console and fill in the required fields.
- Create Play Services credentials for each key (from step 6).
- 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" />
- In your
res/values/strings.xml
, add the following values (replaceXXXXXX
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>
- 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();
Link User with Game Services #
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:
- Open your project in Xcode.
- Navigate to Build Settings under your target.
- 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.