Android Quickstart
This guide walks you through integrating PushEngage push notifications into a native Android application (Java or Kotlin). Estimated time: 15 minutes.
After completing this guide, your app will receive push notifications. See the Android SDK Reference for the full API.
Prerequisites
- Android Studio installed
- Android project with
minSdkVersion16 (Android 4.1) or higher; API 21+ recommended - Firebase account (create one free)
- PushEngage account and App ID (see Get Your App ID)
Every step on this page can be handled by an AI coding agent. Install the official PushEngage Agent Skills in Claude Code, Cursor, or another compatible agent:
npx skills add awesomemotive/pushengage-skills
Then ask it to "integrate PushEngage into this app". The skills walk the agent through the full setup and can also diagnose a broken integration.
Step 1 — Installation
Configure the Repository
If your project uses a settings.gradle file (centralized dependency resolution):
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
If your project uses a project-level build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.google.gms:google-services:4.4.2"
}
}
allprojects {
repositories {
google()
maven { url 'https://jitpack.io' }
}
}
Add the SDK Dependency
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
dependencies {
implementation 'com.github.awesomemotive:pushengage-android-sdk:0.1.0'
implementation platform('com.google.firebase:firebase-bom:33.5.1')
}
Step 2 — Firebase Setup
PushEngage uses Firebase Cloud Messaging (FCM) to deliver push notifications to Android devices.
Create a Firebase Project
- Open the Firebase console and sign in.
- Click Add Project (or select an existing one) and complete the setup wizard.
Add Your Android App
- In the Firebase project dashboard, click the Android icon.
- Enter your app's package name (found in
android/app/build.gradleunderapplicationId). - Click Register app.
- Download google-services.json and place it at
android/app/google-services.json.
Generate Service Account JSON
- Firebase console → Settings icon → Project settings → Service accounts tab.
- Click Generate new private key and save the downloaded JSON file securely.
Retrieve Your Sender ID
- Firebase console → Settings icon → Project settings → Cloud Messaging tab.
- Copy the Sender ID.
Step 3 — Connect to PushEngage Dashboard
- Log in to your PushEngage Dashboard.
- Navigate to Site Settings → Installation → Android SDK tab.
- Enter your Firebase Sender ID.
- Upload your Service Account JSON file.
- Click Update and copy the App ID shown on the page.
Step 4 — Initialize the SDK
If your application does not have a custom Application class, create one:
- Kotlin
- Java
import android.app.Application
import com.pushengage.pushengage.PushEngage
class PEApplication : Application() {
override fun onCreate() {
super.onCreate()
val pushEngage = PushEngage.Builder()
.addContext(applicationContext)
.setAppId("YOUR_APP_ID")
.build()
// Recommended: set a branded small icon instead of the default bell
PushEngage.setSmallIconResource("your_icon_name")
}
}
import android.app.Application;
import com.pushengage.pushengage.PushEngage;
public class PEApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
PushEngage pushEngage = new PushEngage.Builder()
.addContext(getApplicationContext())
.setAppId("YOUR_APP_ID")
.build();
// Recommended: set a branded small icon instead of the default bell
PushEngage.setSmallIconResource("your_icon_name");
}
}
Register the custom Application class in AndroidManifest.xml:
<application
android:name=".PEApplication"
...>
Replace YOUR_APP_ID with the App ID from Step 3. The setSmallIconResource name must match a drawable resource in your res/drawable/ directory. If omitted or invalid, a default bell icon is used.
Step 5 — Request Notification Permission
On Android 13 (API 33) and above, you must request notification permission explicitly. Call this from your main Activity — which must extend ComponentActivity (e.g., AppCompatActivity, FragmentActivity, or androidx.activity.ComponentActivity directly). If your Activity extends plain android.app.Activity, switch its base class first.
- Kotlin
- Java
PushEngage.requestNotificationPermission(this, object : PushEngagePermissionCallback {
override fun onPermissionResult(granted: Boolean, error: Error?) {
if (granted) {
// The SDK automatically subscribes the user when permission is granted
Log.d("PushEngage", "Permission granted and user subscribed")
} else {
Log.d("PushEngage", "Permission denied: ${error?.message}")
}
}
})
PushEngage.requestNotificationPermission(this, new PushEngagePermissionCallback() {
@Override
public void onPermissionResult(boolean granted, Error error) {
if (granted) {
// The SDK automatically subscribes the user when permission is granted
Log.d("PushEngage", "Permission granted and user subscribed");
} else {
Log.d("PushEngage", "Permission denied: " + (error != null ? error.getMessage() : ""));
}
}
});
On Android 12 (API 32) and below, notification permission is automatically granted. The callback fires immediately with granted = true.
Step 6 — Send a Test Notification
- Build and run your app on a physical Android device — push notifications do not work in the emulator.
- Grant notification permission when prompted.
- In the PushEngage Dashboard, go to Campaign → Push Broadcasts → Create New Push Broadcast and send a test.
You should receive the notification within a few seconds. Your integration is complete.
Troubleshooting
Build error: "google-services plugin not applied"
Ensure id 'com.google.gms.google-services' is in the plugins block of your app-level build.gradle, applied after com.android.application.
Notification permission denied — no second prompt
On Android 13+, after denial the system blocks subsequent requestNotificationPermission calls. The only path back is Settings → Apps → <App> → Notifications. Surface a one-tap deep link to Settings.ACTION_APP_NOTIFICATION_SETTINGS in your UI.
Notifications not received on device
- Confirm
google-services.jsonis atandroid/app/google-services.json(not the project root). - Confirm the Sender ID and Service Account JSON in the PushEngage Dashboard match your Firebase project.
- Test on a physical device, not an emulator (FCM requires Google Play Services).
- Enable verbose logging:
PushEngage.enableLogging(true)— watch for the FCM token registration log line.
Notifications work for a while, then stop Some Android device manufacturers aggressively restrict background services for apps the user has force-stopped. Ask affected users to disable battery optimization for your app: Settings → Battery → Battery Optimization → Don't optimize.
Custom small icon not appearing
If setSmallIconResource("name") references a drawable that doesn't resolve, the SDK silently uses a default bell icon. Verify the drawable exists at res/drawable/name.xml (or .png).