Why Firebase?
Threadly’s messaging system uses Socket.IO for real-time communication. However, when the app is in the background or closed, Firebase Cloud Messaging acts as a fallback to ensure users never miss important notifications.Hybrid Notification System
- Socket.IO handles real-time delivery when app is active
- FCM delivers notifications when app is backgrounded or closed
Create a Firebase Project
Go to Firebase Console
Visit console.firebase.google.com and sign in with your Google account.
Configure Google Analytics (optional)
- Choose whether to enable Google Analytics
- Select an Analytics account or create a new one
- Click Create project
Add Android App to Firebase
Add an Android app
From your Firebase project dashboard:
- Click the Android icon to add an Android app
- Or go to Project settings > General > Your apps
Register your app
Fill in the required information:
| Field | Value |
|---|---|
| Android package name | com.rtech.threadly |
| App nickname | Threadly (optional) |
| Debug signing certificate SHA-1 | Optional for development |
The package name must exactly match the
applicationId in your app/build.gradle file.Download google-services.json
- Click Download google-services.json
- Save the file - you’ll need it in the next section
Add google-services.json to Project
Copy google-services.json
Copy the downloaded
google-services.json file to the app/ directory (same level as app/build.gradle).Verify file placement
In Android Studio, you should see
google-services.json under the app module in Project view:Verify Firebase Integration
Threadly already includes the necessary Firebase dependencies and configuration:Gradle Plugin
build.gradle (Project level)
app/build.gradle
Firebase Messaging Dependency
app/build.gradle
FCM Service Implementation
Threadly includes a custom FCM service:AndroidManifest.xml
If you’ve followed all steps, Firebase is now fully integrated!
Enable Cloud Messaging API
Navigate to Cloud Messaging
In Firebase Console:
- Go to Project settings > Cloud Messaging
- Or directly visit:
https://console.firebase.google.com/project/YOUR_PROJECT/settings/cloudmessaging
Configure Backend for FCM
Your backend server needs Firebase Admin SDK credentials to send push notifications:Generate a private key
In Firebase Console:
- Go to Project settings > Service accounts
- Click Generate new private key
- Confirm and download the JSON file
Test Push Notifications
Check FCM token generation
Open Logcat and filter for:You should see logs indicating FCM token generation.
Send a test notification
From Firebase Console:
- Go to Cloud Messaging > Send your first message
- Enter a notification title and text
- Click Send test message
- Enter your FCM token (from Logcat)
- Click Test
Notification Permissions
Threadly requests notification permission at runtime (required for Android 13+):AndroidManifest.xml
Troubleshooting
google-services.json not found
google-services.json not found
- Ensure file is in
app/directory, notapp/src/ - File name must be exactly
google-services.json(case-sensitive) - Perform a Gradle sync after adding the file
- Try File > Invalidate Caches / Restart
No FCM token generated
No FCM token generated
- Check internet connection
- Verify
google-services.jsonmatches your package name - Check Logcat for Firebase initialization errors
- Ensure Firebase Messaging dependency is included
Notifications not received
Notifications not received
- Verify POST_NOTIFICATIONS permission is granted
- Check device battery optimization settings
- Ensure app is registered with FCM (check Logcat for token)
- Verify backend has correct Firebase Admin SDK configuration
- Test with Firebase Console test message first
Duplicate class error during build
Duplicate class error during build
This usually indicates version conflicts. Ensure consistent Firebase versions:
libs.versions.toml
FCM Service Customization
Threadly’s FCM service is located at:Next Steps
Setup Complete! You now have a fully configured Threadly development environment.
Architecture Overview
Learn about Threadly’s MVVM architecture
API Reference
Explore the backend API integration