Docs/Android_Firebase_Setup.md
com.example.bagisto_flutter# Generate SHA-1 from your signing key:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
google-services.jsongoogle-services.json file to:
android/app/google-services.json
Add Google Services plugin dependency:
plugins {
id("com.google.gms.google-services") version "4.4.1" apply false
}
buildscript {
dependencies {
classpath("com.google.gms:google-services:4.4.1")
}
}
Add the Google Services plugin and Firebase dependencies:
plugins {
id("com.android.application")
id("kotlin-android")
id("com.google.gms.google-services")
}
dependencies {
// Firebase
implementation(platform("com.google.firebase:firebase-bom:33.0.0"))
implementation("com.google.firebase:firebase-messaging")
// Other existing dependencies...
}
Update android/app/src/main/AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Existing permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application>
<!-- Existing activities -->
<!-- Firebase Notification Service -->
<service
android:name=".MainActivity"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- Default notification channel -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="bagisto_notifications" />
</application>
</manifest>
The FCM service is already configured in lib/core/notifications/fcm_service.dart.
Firebase Cloud Messaging will be automatically initialized when the app starts.
Build and run your app:
flutter run -d <device_id>
Check the device token in the logs:
🎫 Device token obtained: ...
Send a test notification from Firebase Console:
For release builds, create a signing key:
# Navigate to android directory
cd android
# Create a key
keytool -genkey -v -keystore app-release-key.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias app
# Fill in the prompts (passwords, names, etc.)
Then configure in android/app/build.gradle.kts:
signingConfigs {
create("release") {
storeFile = file("app-release-key.keystore")
storePassword = "your_keystore_password"
keyAlias = "app"
keyPassword = "your_key_password"
}
}
buildTypes {
release {
signingConfig = signingConfigs.getByName("release")
}
}
android/app/ directoryflutter clean && android/gradlew cleanadb logcat | grep -i firebasefirebase_options.dart with your Firebase configuration