How to configure Push Notification for Android
How to Configure Firebase Push Notifications – Android
To send push notifications to your Android app users, you must first configure Firebase Cloud Messaging (FCM) for your application. Follow the steps below to generate the required configuration files and server credentials.
Prerequisites
- A Google account (Gmail ID)
- An Android app package name (e.g., com.company.appname)
- Android Studio project ready (recommended)
Step 1: Create a Firebase Project
- Sign in to the
- Firebase Console using your Gmail account.
- Click Create a project.
- Enter a Project name and click Continue.
- Enable Google Analytics (optional but recommended).
- If enabled, select an existing Analytics account or create a new one.
- Click Create Project.
- Once setup is complete, you will be redirected to the Project Dashboard.
Step 2: Register Your Android App in Firebase
- On the Firebase project dashboard, click the Android icon (</>).
- Enter the required app details:
- Android package name (must match your app exactly)
- App nickname (optional)
- Debug signing certificate SHA-1 (optional, but recommended for some services)
- Click Register App.
Step 3: Download Firebase Configuration File
- After registering the app, download the google-services.json file.
- Place this file inside your Android project at:
app/google-services.json - Click Next and complete the remaining setup steps shown in Firebase (Gradle configuration).
Step 4: Enable Firebase Cloud Messaging (FCM)
- In the Firebase Console, go to Project Overview → Project Settings.
- Open the Cloud Messaging tab.
- Ensure Firebase Cloud Messaging API is enabled.
Step 5: Generate Server Credentials (Service Account Key)
- From Project Settings, go to the Service Accounts tab.
- Under Firebase Admin SDK, click Generate new private key.
- Confirm the action.
- A JSON private key file will be downloaded to your computer.
Important: This file is highly sensitive. Do not expose it in client apps or public repositories.
Where These Files Are Used
- google-services.json
Used in the Android app to connect it with Firebase services. - Service Account JSON (Server Key)
Used on your backend/server to send push notifications securely via Firebase Admin SDK.
Important Notes
Security
- Never embed server keys or service account JSON files inside the Android app
- Restrict access to Firebase credentials
Notification Permission (Android 13+)
- For Android 13 (API 33) and above, you must request POST_NOTIFICATIONS runtime permission from users
Recommended Setup
- Use Firebase Admin SDK on your server for sending notifications
- Use topic-based messaging where applicable for scalability
- Firebase Push Notifications are now configured for your Android app.
