# Firebase Cloud Messaging

The **Firebase Cloud Messaging** module manages Service Account credentials for delivering push notifications to mobile (iOS/Android) and web clients via Google Firebase Cloud Messaging (FCM). When bound to a [Push Notification Template](/push-notification-template) and [Notification](/notification) rule, it automates real-time push alert delivery.

---

## How it works

1. **Upload Service Account JSON** — provide the full `serviceAccountJSON` credentials generated from your Firebase Console.
2. **Auto-parsed parameters** — the system extracts `projectId`, `clientEmail`, and `privateKeyId` from the JSON payload.
3. **Link to Push Templates** — select this integration record (`integrationId`) in your [Notification](/notification) rules when using `integrationProvider: firebase_cloud_messaging`.
4. **Deliver push alerts** — active notification rules render push content and send real-time push messages via FCM API v1.

---

## Fields

### Basic information

| Field | Type | Required | Max length | Description |
|---|---|---|---|---|
| `name` | string | ✅ | 256 | The name of the Firebase Cloud Messaging integration record |
| `description` | string | ❌ | 1 024 | A brief description of the integration setup |
| `status` | enum | ✅ | `draft` | Status of the integration: `draft` · `live` · `paused` |

### Firebase credentials & service account

| Field | Type | Required | Description |
|---|---|---|---|
| `serviceAccountJSON` | JSON | ✅ | The complete Firebase Service Account JSON object. Encrypted at rest and in transit (returned on create only). |
| `projectId` | string | Read-only | Automatically extracted Firebase project ID (e.g. `gamopanda-app`) |
| `clientEmail` | string | Read-only | Automatically extracted service account client email address |
| `privateKeyId` | string | Read-only | Automatically extracted private key identifier |

---

## Real-world examples

**📱 Creating a Firebase Cloud Messaging Integration**

```json
{
  "name": "Production FCM Gateway",
  "description": "Firebase Cloud Messaging service account for Android and iOS push notifications.",
  "serviceAccountJSON": {
    "type": "service_account",
    "project_id": "yourprojectid",
    "private_key_id": "yourprivatekeyid",
    "private_key": "yourprivatekey",
    "client_email": "yourclientemail",
    "client_id": "yourclientid"
  },
  "status": "live"
}
```

---

## Access & permissions

| Caller | Allowed operations | Notes |
|---|---|---|
| Admin | CREATE · GET · LIST · UPDATE · DELETE | Full management access |
| End user | *(none)* | No access |
| Guest user | *(none)* | No access |

---

## Related resources

| Resource | Description |
|---|---|
| [Push Notification Template](/push-notification-template) | Push title, body, and deep link templates |
| [Notification](/notification) | Active notification rules targeting FCM integration |
| [Notification Log](/notification-log) | Read-only delivery logs recording execution history |

---

## API reference

See the [API Reference](/api/firebase-cloud-messaging) for full schemas and interactive examples for:

- `GET /schema/firebase_cloud_messaging/record` — list FCM integration records
- `POST /schema/firebase_cloud_messaging/record` — create an FCM integration record
- `GET /schema/firebase_cloud_messaging/record/{id}` — get an FCM integration record by ID
- `PATCH /schema/firebase_cloud_messaging/record/{id}` — update an FCM integration record
- `DELETE /schema/firebase_cloud_messaging/record/{id}` — delete an FCM integration record
