In this tutorial, we walk you through the steps to configure Firebase Cloud Messaging (FCM) with brainCloud.


Use the FCM API key for brainCloud

Get the FCM Server Key

  • Navigate your browser to the Firebase console

  • Select your app

  • Click the Settings Icon, “Project Settings” in the top left nav bar.

  • Select “Cloud Messaging” and copy the Server Key

Save the Server Key in the brainCloud Portal

  • Navigate to the brainCloud portal and enter this key in the Notifications | Settings for Google Play.

Enable FCM For Your App

In addition to the above steps, you will need to do the following in order for FCM to work in your app.

Get the google-services.json file

This file can be found in the Firebase dashboard, and contains most the credentials you’ll need to connect your app to Firebase.

  • Navigate to the General Tab in the Firebase Project Settings

  • Download the google-services.json file

  • Add the downloaded file to your app

  • If using Unity, you can use the brainCloud example at this link, be sure login and select your app

Registering FCMNotification Token With brainCloud

After Authenticating a user with brainCloud, you will want to Register their FCMnotification token with brainCloud. Specifically, you’ll want to call the BrainCloudPushNotifications.RegisterDeviceToken() and pass in the registration id. In order to get this registration id, follow these steps.

Note that this example assumes you are working in Java on an Android device. For developers using Unity (or a Unity plugin such as GamePlayServices), follow the appropriate instructions available elsewhere.

  .addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
      public void onComplete(@NonNull Task<InstanceIdResult> task) {
          if (!task.isSuccessful()) {
              Log.w(TAG, "getInstanceId failed", task.getException());

          // Get new Instance ID token
          String token = task.getResult().getToken();
          _bc.GetWrapper().getPushNotificationService().registerPushNotificationToken(Platform.GooglePlayAndroid, token, theCallback);

Did this answer your question?