App Center Push


For Android developers using App Center, there is a change coming where Firebase SDK is required to use Push Notifications. For Android P, its required at the release date for the latest OS version. For all other versions of Android, it will be required after April 2019. For additional information, please refer to the App Center React Native migration guide.

App Center Push enables you to send push notifications to users of your app from the App Center portal. App Center portal and the Push SDK is integrated with Firebase Cloud Messaging.

Only devices with the Google Play Store application or emulators using Google APIs images can receive notifications.


A notification appears in the system notification center only if the application is in the background at the moment the Push is received.


1. Set up Firebase Cloud Messaging

  1. Create a project on the Firebase Console.
  2. Click the Android logo on the page to create an application matching your package name.
  3. Go to Project Settings and download the google-services.json file.
  4. Copy this file to your Android project app module.

2. Obtain your Android API Key

  1. In the Firebase Console, go to Project Settings.
  2. Navigate to the Cloud Messaging tab.
  3. Copy the Server Key. This will be the Android API Key that you will need to set in the App Center Push portal.

Add App Center Push to your app

Please follow the Get started section if you haven't set up and started the SDK in your application, yet. The App Center SDK is designed with a modular approach – you only need to integrate the services that you're interested in.

First, open a Terminal and navigate to the root of your React Native project. Then, enter the following to add App Center Push to the app:

npm install appcenter-push --save-exact

Integrate Firebase in your application

  • Copy the google-services.json file to your Android project app module folder (it should be android/app folder for most projects).

  • Modify the android/build.gradle file:

    buildscript {
        repositories {
            // Add google line if missing before jcenter
        dependencies {
            // Add this line
            classpath ''
    allprojects {
        repositories {
            // Add google line if missing before jcenter


    Google introduced the google() repository with Gradle v4. If your Gradle version is lower than v4, then you need to use maven { url '' } instead of google().

  • Modify the android/app/build.gradle file:

    // Add this line at the bottom
    apply plugin: ''

Intercept push notifications

You can set up a listener to be notified whenever a push notification is received in foreground or a background push notification has been clicked by the user.


A notification is not generated when your application receives a push in the foreground.


If the push is received in background, the event is NOT triggered at receive time. The event is triggered when you click on the notification.


The background notification click callback does NOT expose title and message. Title and message are only available in foreground pushes.

You need to register the listener when your app starts. A convenient place to do that is at the outer level in the .js file for your root component:

import Push from 'appcenter-push';
import { AppState, Alert } from 'react-native';

class MyApp extends Component {

  onPushNotificationReceived: function (pushNotification) {
    let message = pushNotification.message;
    let title = pushNotification.title;

    if (message === null) {
      // Android messages received in the background don't include a message. On Android, that fact can be used to
      // check if the message was received in the background or foreground. For iOS the message is always present.
      title = 'Android background';
      message = '<empty>';

    // Custom name/value pairs set in the App Center web portal are in customProperties
    if (pushNotification.customProperties && Object.keys(pushNotification.customProperties).length > 0) {
      message += '\nCustom properties:\n' + JSON.stringify(pushNotification.customProperties);

    if (AppState.currentState === 'active') {
      Alert.alert(title, message);
    else {
      // Sometimes the push callback is received shortly before the app is fully active in the foreground.
      // In this case you'll want to save off the notification info and wait until the app is fully shown
      // in the foreground before displaying any UI. You could use AppState.addEventListener to be notified
      // when the app is fully in the foreground.

If (and only if) your launcher activity uses a launchMode of singleTop, singleInstance or singleTask, you must override the onNewIntent method. Inside the Java code for your launcher activity (typically the file), add the following:

import android.content.Intent;

public void onNewIntent(Intent intent) {
    Push.checkLaunchedFromNotification(this, intent);

Custom data in your notifications

You can send optional custom data as part of the push payload. The data will be sent in the key-value format. This custom data can be intercepted in the app through Push SDK callback.

There are few reserved keywords that can be set via custom data. You can customize your notifications by setting custom color, icon or sound.


Android 5.0 and later uses a silhouette (only alpha channel) of your icon for notifications. See Android 5.0 Behavior Changes for details.

Reserved keywords in Android platform

  • color: The notification's icon color, expressed in #rrggbb format. Will be applied only on devices with Android 5.0 and later.
  • icon: The notification's icon. You should specify name of the icon resource. Supports drawable and mipmap types. If this value isn't specified application icon will be used.
  • sound: Add this key when you want the to play a sound when the device receives the notification. Supports default or the filename of a sound resource bundled in the app. Sound files must reside in /res/raw/. This is effective only for devices running or targeting an Android version lower than 8. Sound is set by default on Android 8 and user can change notification settings for the group of notifications coming from AppCenter.

Configure notification's default values

You can specify custom defaults for the icon and color that gets applied when it isn't set in the push payload.

The lines below should be added to AndroidManifest.xml inside the application tag:

<!-- Set default notification icon and color. -->
    android:resource="@drawable/ic_notification" />
    android:resource="@color/notification" />

App Center displays the application icon if a custom default icon and an icon are not set in the push payload.

Existing Firebase Analytics users

The App Center Push SDK automatically disables Firebase Analytics. If you are a Firebase customer and want to keep reporting analytics data to Firebase, you must call a method to enable it by default. To do this, look for the onCreate method in the file and add the following before SoLoader.init:

SoLoader.init(this, false);

Enable or disable App Center Push at runtime

You can enable and disable App Center Push at runtime. If you disable it, the SDK will stop updating the Google registration identifier used to push but the existing one will continue working. In other words, disabling the App Center Push in the SDK will NOT stop your application from receiving push notifications.

import Push from 'appcenter-push';


await Push.setEnabled(false);      // Disable push
await Push.setEnabled(true);       // Re-enable it

The state is persisted in the device's storage across application launches.

Check if App Center Push is enabled

You can also check if App Center Push is enabled or not:

import Push from 'appcenter-push';


const pushEnabled = await Push.isEnabled();

Delay first time initialization of Push

If you want to delay Push initialization the first time the application is run:

  • Edit the android/app/src/main/assets/appcenter-config.json file.
  • Add , "enable_push_in_javascript": true before the last } of the file.
  • Once you get approval from the user to use Push at runtime, call Push.setEnabled(true).

After calling Push.setEnabled(true) once, App Center Push will be started automatically the next time the application restarts.