Notice: There is no legacy documentation available for this item, so you are seeing the current documentation.
Getting Started
Do you have an android application where you want to add push notifications? In this tutorial, we will show you how to integrate PushEngage with your Android application. Let’s understand step by step how to get started with app push notifications.
Setup Firebase Project
Before you get started with app push notifications you need to ensure that you have an existing firebase account.
- You need to Login into Firebase console, using your Google account.
- Click Add Project or select an existing project. Skip to step 4 if you choose an existing project.
- Enter a project name and click Continue. On the next screen click Create project
- Click on the Android icon to add an Android app in the project.
- On the following screen enter your Android applications package name and give the name of the Android App you are trying to integrate and click register.
- Download the google-services.json file and place it into your Android app module root directory.
- Get the Firebase Server key and Sender ID required for PushEngage Setup and Integration.
- In the Firebase console click the Settings icon next to Project overview in the top left and Select Project settings.
- select Cloud Messaging tab on Project settings page and copy the Server Key and Sender ID listed under Project Credentials section. These values are required to while integrating FCM with PushEngage
Integrate FCM with PushEngage Dashboard
Once you have created the project in Firebase you can then move ahead to integrate the Firebase server key and sender ID in PushEngage dashboard.
- You need to Login to your PushEngage account.
- Navigate to Settings > Site Settings > Installation Settings in the sidebar.
- In the Native App Platform section, select Android Tab.
- Configure your FCM settings by adding Firebase Server Key and Firebase Sender ID.
- Copy the App ID required to initialize the PushEngage Android SDK in your app.
Adding SDK Dependencies
Now that we are done with the configuration in PushEngage & Firebase console we need to move ahead and integrate the PusheEngage Android SDK in your Android app.
- In project level
build.gradle
file add the following lines.
// Project level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
// ...
// Add this line
classpath "com.google.gms:google-services:4.3.10"
}
}
allprojects {
repositories {
// ...
// Check that you have the following line (if not, add it):
google()
maven {url 'https://jitpack.io' }
}
}
- In your App level
build.gradle
file add the following lines.
plugins {
id 'com.android.application'
// Add this line
id 'com.google.gms.google-services'
}
dependencies {
// ...
// Add the following lines
implementation 'com.github.awesomemotive:pushengage-android-sdk:0.0.3'
implementation platform('com.google.firebase:firebase-bom:26.1.1')
}
Initializing the SDK
Add the pushengage SDK initialization code block to the onCreate
method in the Application class. PUSHENGAGE_APP_ID should be replaced by the App Id that you got from the PushEngage dashboard.
public class PEApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// PushEngage SDK Initialization code
PushEngage pushEngage = new PushEngage.Builder()
.addContext(getApplicationContext())
.setAppId("PUSHENGAGE_APP_ID")
.build();
// The small icon is displayed on the top status bar and in the notification.
// By default PushEngage displays a bell icon, however It is recommended to
// customize this so users easily recognize notifications from your app.
PushEngage.setSmallIconResource("icon");)
}
}
Once you have configured all the above steps you are ready to send push notifications to your Android app. Build and run the application on a physical device and send test push notifications from PushEngage Dashboard.
If you have any concerns or run into issues you can always write to care@pushengage.com.