How to set up android app push notifications with PushEngage

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.

  1. You need to Login into Firebase console, using your Google account.
  2. Click Add Project or select an existing project. Skip to step 4 if you choose an existing project.
  1.  Enter a project name and click Continue. On the next screen click Create project
  1. Click on the Android icon to add an Android app in the project.
  1. 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.
  1. Download the google-services.json file and place it into your Android app module root directory.
  1. Get the Firebase Server key and Sender ID required for PushEngage Setup and Integration.
    1. In the Firebase console click the Settings icon next to Project overview in the top left and Select Project settings.
  1. 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.

  1. You need to Login to your PushEngage account.
  2. Navigate to Settings > Site Settings > Installation Settings in the sidebar.
  3. In the Native App Platform section, select Android Tab.
  4. Configure your FCM settings by adding Firebase Server Key and Firebase Sender ID.
  5. 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.

  1. 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' }
   }
}
  1. 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.

Still stuck? How can we help?
Last updated on July 20th, 2022

Engage and Retain Visitors AfterThey’ve Left Your Website

Increase the value of every web visit with Push Notifications that are hard to miss.

  • Forever Free Plan
  • Easy Setup
  • 5 Star Support