# 10.4 Messaging

Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably send messages at no cost.

<https://firebase.google.com/docs/cloud-messaging>

## In-app Messaging

{% embed url="<https://firebase.google.com/docs/in-app-messaging>" %}

![An example In-app message](/files/-MZiYC8z8ofq8JZ8TglL)

Firebase In-App Messaging helps you engage your app's active users by sending them targeted, contextual messages that encourage them to use key app features. For example, you could send an in-app message to get users to subscribe, watch a video, complete a level, or buy an item. You can customize messages as cards, banners, modals, or images, and set up triggers so that they appear exactly when they'd benefit your users most.

To use In-App Messaging, you must first add it's SDK to your Android app (make sure your Firebase project is set up, the steps of which are covered in the first section 11.1 and that your analytics are set up, covered in 11.3!)

```
dependencies {
    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:27.1.0')

    // Declare the dependencies for the In-App Messaging and Analytics libraries
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-inappmessaging-display-ktx'
    implementation 'com.google.firebase:firebase-analytics-ktx'
}
```

To create an In-app message campaign, visit <https://console.firebase.google.com/project/_/inappmessaging/> where you can specify how your notification should look like, and who to target based on any created users from Audiences or specific event triggers from setting up your Analytics!

![Testing notifications](/files/-MZiZuWQP8Vc0XmA3VbG)

When creating a notification, you can test it by specifying something called the **installation ID:**

### Get your app's installation ID

To conserve power, Firebase In-App Messaging only retrieves messages from the server once per day. That can make testing difficult, so the Firebase console allows you to specify a test device that displays messages on demand.

That testing device is determined by a [`FirebaseInstallations`](https://firebase.google.com/docs/reference/android/com/google/firebase/installations/FirebaseInstallations) ID, or FID. Find your testing app's FID by checking the Logcat in Android Studio for the following \`Info\` level log:

```
I/FIAM.Headless: Starting InAppMessaging runtime with Installation ID YOUR_INSTALLATION_ID
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://android-course.cornellappdev.com/chapters/11.-firebase/11.4-messaging.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
