> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/push/integrations/providers/fcm.md).

# Firebase Cloud Messaging

Connect Firebase Cloud Messaging (FCM) to Push, for Android and iOS apps.

Firebase Cloud Messaging (FCM) is Google's free service that delivers notifications to Android apps, and to iOS apps that use the Firebase SDK. Norbix signs in to Firebase with a **service account** of your Firebase project.

{% hint style="warning" %}
On our test stack the integration saves, but **Test integration** fails with *Some settings are not defined (Parameter 'settings')* before Firebase is called. Sending through FCM could not be confirmed; the question is open in the docs program. Use [Fake Push (Test Me)](/codemash/cloud/push/integrations/providers/fake.md) to try your flows meanwhile.
{% endhint %}

## Get your credentials

1. Open the [Firebase console](https://console.firebase.google.com/) and pick your project (or **Add project**). Add your Android app (and iOS app) to it.
2. **Project settings → General**: copy the **Project ID**, e.g. `acme-shop`.
3. **Project settings → Service accounts → Generate new private key → Generate key**. A JSON file is downloaded. Its `client_email` value is the **Service Account Client Email**; the whole file is the **Service Account JSON**.

The JSON file is a full credential: anyone holding it can send notifications as your app. Keep it secret, and generate a new key if it leaks. The three fields must come from the same Firebase project.

## Connect it in Cloud

**Where:** Push → Integrations → **Add New Integration** → Firebase Cloud Messaging → **Connect** · `/projects/<project>/push/integrations/new/fcm`

| Field                        | Required | What it does                                                          | Example                                                         |
| ---------------------------- | -------- | --------------------------------------------------------------------- | --------------------------------------------------------------- |
| Firebase Project Id          | yes      | *Find this in the Firebase console under Project Settings → General.* | `acme-shop-docs`                                                |
| Service Account Client Email | yes      | The `client_email` value of the JSON file.                            | `firebase-adminsdk-docs@acme-shop-docs.iam.gserviceaccount.com` |
| Service Account JSON         | yes      | The whole JSON file. Encrypted on save and never shown again.         | `{"type":"service_account",…}`                                  |
| Integration Name             | yes      | The name in your integrations list.                                   | `Acme Android app (FCM)`                                        |

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-5e47917e27139158187bc1fd03db511e03dba09b%2Ffcm-form-1.png?alt=media" alt="New Firebase Cloud Messaging Integration form filled with Firebase Project Id acme-shop-docs, the client email, the service account JSON (hidden) and Integration Name Acme Android app (FCM)"><figcaption><p>The filled form (the service account is made up for the docs).</p></figcaption></figure>

Press **Save**. The page turns into **Editing Firebase Cloud Messaging integration** with the integration id and the badges **ENABLED**, **NOT TESTED**, **NOT CONFIRMED**. The JSON is not shown again; paste it again when you change anything.

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-0e23732c6abdbd573c40dd462390bff22fd1e121%2Ftest-1.png?alt=media" alt="Editing Firebase Cloud Messaging integration with the badges ENABLED, NOT TESTED, NOT CONFIRMED, the project id and client email filled and the Service Account JSON empty"><figcaption><p>After save.</p></figcaption></figure>

## Test and set as default

Press **Test integration** at the bottom of the page — see [Test an integration](/codemash/cloud/push/integrations/test.md), which shows this integration's failed test. Then choose **Actions → Set as default** if campaigns should pick it — see [Set an integration as default](/codemash/cloud/push/integrations/set-default.md).

## Common errors

| Message                                                                                 | Cause                                   | Fix                                             |
| --------------------------------------------------------------------------------------- | --------------------------------------- | ----------------------------------------------- |
| Could not send push via Firebase … Some settings are not defined (Parameter 'settings') | Seen on every test on our stack.        | Open question; use the Fake provider meanwhile. |
| Required                                                                                | An empty field — on edit also the JSON. | Fill every field, paste the JSON again.         |
