Google Firebase

Prerequisites

Use the FCM API key for brainCloud

Get the FCM Server Key

  • Navigate your browser to the Firebase console and select your project
  • 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

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.

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

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

Note: once a user device is registered to brainClound from your app, you can check it from User Monitoring | User Summary page.

Setup – iOS Development Center

Prerequisites

  • Must have an iOS developer account
  • In order to configure brainCloud to send notifications to your iOS app, you will need to provide a p12 certificate file. Follow these steps to create a p12 file for your app.

brainCloud Portal Configuration

  • Log into the brainCloud portal
  • Navigate to “Notifications | Settings” in the design tab for your app
  • Click on the edit button for the Apple notification settings
  • Upload your p12 file and enter the password that was used to create the p12 file into the dialog
  • Notice that once you’ve done that, the type of certificate shows up (production/sandbox) as well as the expiry date
Did this answer your question?