2. Integrate Android SDK

Once you have properly configured FCM you will need to integrate the Pusher & FCM SDKs into your project. In this guide we will assume that you are using Gradle and Android Studio.

Add Firebase config file to your project

Have you downloaded the google-services.json config file from your Firebase project console? If not, see this video.

Move config file into project

Move your google-services.json config file into your Android Studio project, in the app directory:

YOUR_ANDROID_PROJECT/app/google-services.json
If you are following the quick start guide in the Pusher Beams dashboard, you can return to it now.

Update your project-level gradle config

Add the Google Services classpath to the dependencies section of your project-level build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
 
buildscript {
 
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        // Add this line
        classpath 'com.google.gms:google-services:4.2.0'
 
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
 
allprojects {
    repositories {
        google()
        jcenter()
    }
}
 
task clean(type: Delete) {
    delete rootProject.buildDir
}

Update your app-level gradle config

In order to update your app-level build.gradle you will need to:

  • Add the Firebase Messaging SDK to your dependencies
  • Add the Beams SDK to your dependencies
  • Add the Google Services plugin to the end of the file
apply plugin: 'com.android.application'
 
android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.exampleapp"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
 
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    // Add these lines
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
    implementation 'com.pusher:push-notifications-android:1.4.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
 
// Add this line to the end of the file
apply plugin: 'com.google.gms.google-services'

Synchronize Gradle

Synchronize Gradle by pressing the "Sync Now" button:

Gradle 'Sync Now' button in Android Studio

Where Next?

Now that you integrated the Android SDK into your project, you can initialize Pusher Beams.