# Firebase Cloud Messaging Streaming Output Integration

Firebase Cloud Messaging (FCM) is **cross-platform messaging solution that allows to reliably send messages.**

With this integration you can send messages to the channels such as email, SMS or Line with real-time trigger activations

## Prerequisites

- Basic knowledge of Treasure Data
- Basic knowledge of FCM, including knowledge project, app in [FCM website](https://firebase.google.com/docs/projects/learn-more) features
- Login credentials for your Firebase Cloud Messaging account


## Use Cases

The primary use case for this streaming integration is to incorporate it into a real-time activation workflow to:

- Trigger a message delivery to FCM


Here is an overview of how to configure that workflow to trigger a delivery:

1. On the FCM website, learn about how to create a project [Firebase Project](https://firebase.google.com/docs/projects/learn-more#setting_up_a_firebase_project_and_registering_apps) features necessary to send messages.
2. On the FCM console, select your project and create a new app according to your platform.
3. On the FCM console, select your app and go to app configuration. Get the app config as `google-services.json` in JSON format.
4. Create an authentication for this integration to communicate with Firebase Cloud Messaging.
5. In a Real-time Journey, select this authentication for a new triggered activation.


## Requirements and Limitations

- This connector limitation follow the FCM limitations. Please refer to [FCM Quotas and Limits](https://firebase.google.com/docs/cloud-messaging/throttling-and-quotas).


## Static IP Address of Treasure Data Integration

If your security policy requires IP whitelisting, you must add Treasure Data's IP addresses to your allowlist to ensure a successful connection.

Please find the complete list of static IP addresses, organized by region, at the following [document](/apis/endpoints/ip-addresses-integrations-result-workers)

## Firebase Cloud Messaging Streaming Export via Treasure Console

You must create and configure the data connection in Treasure Data. As part of the data connection, you provide authentication credentials to access the integration.

### Create Authentication

Perform the following steps to create a new authentication with a set of credentials.

1. Select Integrations Hub.
2. Select Catalog.
3. Search for your Integration in the Catalog; hover your mouse over the icon and select Create Authentication.
![Firebase Cloud Messaging connector tile in the Integrations Hub Catalog](/assets/fcm-streaming-logo.775e2c07547af866fae4df4d7920423fe358cfe1746dd9d365bdfa5ed4e1c559.171e1ecf.png)
![Create Authentication button displayed when hovering over the Firebase Cloud Messaging connector](/assets/fcm-streaming-authen.e6379fd330eb1be6a624ce4203915373e48ea63c44bd1ecd62f9661979f968a6.171e1ecf.png)
4. Ensure that the Credentials tab is selected and then enter credential information for the integration.


### New Authentication Fields

![Authentication configuration screen showing the Private Key In JSON File field](/assets/fcm-streaming-authen-detail.17bc9d9feab76aa4965a37b5f305a6f8bd9c064d3fd3170a8b8ff91611d96e6d.171e1ecf.png)

| Parameter | Description |
|  --- | --- |
| Private Key In JSON File | The JSON credential of the App in Project |


1. Select **Continue**.
2. Enter a name for your connection.
3. Select **Done.**


After configuring the Firebase Cloud Messaging Streaming integration, it is now available to be incorporated into real-time customer journey activations. See [Creating a Real-time Triggered Activation](https://docs.treasuredata.com/smart/project-product-documentation/creating-a-real-time-triggered-activation) for additional information.

### Real-time Triggered Activation

To create or update a triggered activation:

1. Select the triggered activation you want to configure ![](/assets/triggeredactivation.66e546b8c4cc774c0bdd804d0d099b63cf12b1916181d85d7c715be95bd61810.9e7171ae.png).


![](/assets/fcm-streaming-basic-activation-config.7302db891dcfdca12a3de454a437eb2ddeb4859a9e454dea10b7df288ddb2e23.171e1ecf.png)

1. In the triggered activation window, select an activation from the Copy triggered activation from drop-down menu.
2. Enter a Triggered activation name.
3. Enter an Optional description of the activation.
4. From the Authentication drop-down menu, select the authentication the activation should use.


Depending on the type of authentication you choose, the details you will need to provide will vary. Refer to the integration-specific table below for more information.

![Firebase Cloud Messaging Output Streaming Activation Config](/assets/fcm-streaming-triggered-activation.2249016fb43343efe94ac30ee575a8544e9e6ef408fcd702a72a36c01b96b256.171e1ecf.png)

1. Verify or provide the information required for the fields on the Details page.
2. After the Details are configured, select **Create** or **Update**.


### Integration Parameters

| Parameter | Values | Description |
|  --- | --- | --- |
| **Name** | required - String | The identifier of the message sent, in the format of projects/*/messages/{message_id}. |
| **Target** | Token - Topic - Condition, default Token | We will support multiple targets, as provided by the Firebase platform: Token, Topic, Condition |
| **Data** | required - JSON | The Data will be sent with the message. Arbitrary key/value payload, which must be UTF-8 encoded. |
| **Notification** | required | The notification payload to be sent with the message. |
| **Android** | optional | The Android-specific options for the message. |
| **APNs** | optional | Apple Push Notification service options for the message |
| **FCM Options** | optional | FCM options for the message |
| **Maximum Number Of Retry** | optional, default 3 | Number of retries before it gives up. |
| **Initial Retry Delay** | optional, default -2 | How long wait before retrying the first one |
| **Retry Delay Multiple** | optional, default 2 | The factor to multiply the delay after each retry |


Union field target. Required. Input only. Target to send a message to. target can be only one of the following:

| Target | Type | Description |
|  --- | --- | --- |
| **Token** | string | Registration token to send a message to. |
| **Topic** | string | Topic name to send a message to, e.g. "weather". Note: "/topics/" prefix should not be provided. |
| **Condition** | string | Condition to send a message to, e.g. "'foo' in topics && 'bar' in topics". |


## Retry and Logging Logic

- The connector will retry to send the request when it gets the status code 429, 500, 502, 503, or 504.
- If the request is sent successfully before the **Maximum Number of Retry** is reached, the logging will show successfully.
- If the request still fails after reaching the **Maximum Number of Retry**, the connector will stop the job.
- We will see the error message and the status code in the client's activation table whenever the request sent fails.
- The **Maximum Number of Retry** can be configured in the Activation Config.