If you’re developing an Android application and want to implement push notifications, OneSignal is one of the most efficient services available. This article provides a step-by-step guide on how to integrate OneSignal with Firebase and configure your Android project to send push notifications effectively.

Step 1: Create and Set Up Your Firebase Project
- Visit the official Firebase Console: https://console.firebase.google.com/.
- Click on “Add Project” and enter your project name.
- Accept the terms and click “Create Project”.
- Once your project is created, click “Continue” to enter the Firebase project dashboard.
Step 2: Register Your Android App in Firebase
- In the Firebase dashboard, click the Android icon to register your app.
- Enter your app’s package name (you can find it in your app’s
AndroidManifest.xml). - (Optional) Provide a nickname and SHA-1 key if needed.
- Click “Register App”.
Step 3: Download and Add google-services.json File
- After registration, download the
google-services.jsonfile. - Move this file into your app’s
app/directory in Android Studio.
Step 4: Configure Your Android Project for Firebase
- In your project-level
build.gradle, add the following classpath:
classpath 'com.google.gms:google-services:4.3.15' // or latest version
- In your app-level
build.gradle, apply the plugin at the bottom:
apply plugin: 'com.google.gms.google-services'
- Sync your project to ensure the Firebase SDK is added.
Step 5: Enable Firebase Cloud Messaging (FCM)
- Go to Project Settings > Cloud Messaging in Firebase.
- Ensure that Cloud Messaging API (Legacy) is enabled.
- Copy the Server Key and Sender ID—you will need these for OneSignal.
Step 6: Set Up Your OneSignal Account
- Visit https://onesignal.com/ and sign up or log in.
- Click “New App/Website” and give it a name.
- Choose “Google Android” as the platform.
- Paste your Firebase Server Key and Sender ID when prompted.
- Click “Save & Continue”.
Step 7: Integrate OneSignal in Your Android App
- In your app-level
build.gradle, add the OneSignal dependency:
implementation 'com.onesignal:OneSignal:[4.8.5, 4.99.99]'
- In the
onCreate()method of yourApplicationclass, initialize OneSignal:
OneSignal.initWithContext(this);
OneSignal.setAppId("YOUR-ONESIGNAL-APP-ID");
Replace "YOUR-ONESIGNAL-APP-ID" with the one generated in your OneSignal dashboard.
- Sync your project.
Step 8: Add Internet Permission and Update Manifest
In your AndroidManifest.xml, ensure the following permissions and services are present:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<!-- Inside the <application> tag -->
<meta-data
android:name="com.onesignal.app_id"
android:value="YOUR-ONESIGNAL-APP-ID"/>
Step 9: Configure OneSignal Dashboard
- In your OneSignal dashboard, under Settings > Messaging, enable Push Notifications.
- You can also enable In-App Messages, Email, or SMS depending on your app requirements.
Step 10: Test the Notification
- Install your app on a device.
- Open the app once (OneSignal will register the user).
- In OneSignal, go to Audience > All Users.
- Click on your test user and send a test push notification.
Tips:
- If Firebase or OneSignal requires email verification, check your inbox to complete the setup.
- Ensure that you copy-paste keys and IDs accurately without leading/trailing spaces.
- You can manage message formats, scheduling, and automation directly from the OneSignal dashboard.
Conclusion
Integrating OneSignal with Firebase for Android push notifications is a powerful way to enhance user engagement. Following the steps in this article, you can seamlessly set up OneSignal to work with your Firebase-backed Android app. This process not only ensures delivery of timely messages but also allows for analytics and user segmentation.
For more in-depth tutorials like this, keep referring to this blog.
Tags:
Firebase integration, OneSignal Android setup, push notifications Android, Firebase Cloud Messaging, Android app development, notification service setup
Hashtags:
#Firebase #OneSignal #AndroidDevelopment #PushNotifications #FCM #AppDevelopment #TechTutorial