Docs

  • Channels Channels
  • Beams Beams
  • Developers
  • Support
  • Blog
  • Sign up
    • Search powered by Algolia
    • Sign in
    • Sign up
    • Channels
    • Beams
    • Getting started
      • Android
        • 1. Configure FCM
        • 2. Integrate SDK
        • 3. Initialize Beams
        • 4. Publish Notifications
      • iOS
        • 1. Configure APNS
        • 2. Integrate SDK
        • 3. Publish Notifications
      • Web
        • 1. SDK integration
        • 2. Safari configuration
      • Flutter
        • 1. Configure FCM and APNS
        • 2. Integrate SDK
        • 4. Publish Notifications
    • Concepts
      • Subscribers
      • Device interests
      • Authenticated users
      • Insights
      • Webhooks
    • Guides
      • Handle incoming notifications
        • Android
        • iOS
        • Web
        • Flutter
      • Publishing to multiple devices
      • Publish to specific user
        • Android
        • iOS
        • Web
        • Flutter
      • Web push guides
        • Using an existing service worker
        • Web notification permissions in Firefox
        • Handling Safari certificate expiration
    • Reference
      • Client SDKs
        • Android
        • iOS
        • Web
      • All Libraries
      • Server SDKs
        • Go
        • PHP
        • Node.js
        • Python
        • Java/Kotlin
        • Ruby
        • Swift
      • API
        • Publish API
        • Customer API
        • Device API
        • Reporting API
        • Webhooks
      • Platform Publish Formats
    • Pusher lab

    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.
    Hey! Your browser does not support videos!

    ∞ 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:20.2.3'
    implementation 'com.pusher:push-notifications-android:${ANDROID_SDK_VERSION}'
    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.

    Contents

    • Add Firebase config file to your project
      • Move config file into project
    • Update your project-level gradle config
    • Update your app-level gradle config
    • Synchronize Gradle
    • Where Next?

    Spotted something that isn’t quite right? Create an issue on GitHub.

    Copyright © 2024 Pusher Ltd. All rights reserved.

    • Support,
    • Status
    • Follow Pusher on Twitter Twitter
    • Subscribe to Pusher’s channel on YouTube
    • Follow Pusher on LinkedIn
    • Follow Pusher on Github GitHub
    • Follow Pusher on Twitch Twitch
    • Follow Pusher on Discord Discord