> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pgw.sipmicro.services/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure an Android app

> Create a Firebase service account for your Android app and register the app in pgw with its Firebase project ID and number.

When you finish this page, pgw can wake your Android app for a call. Android wakes a closed app through Firebase Cloud Messaging (FCM), Google's push service. FCM is free. It delivers a message to an app only when the message comes from the Firebase project that the app was built for. So you create a Firebase project, build its configuration into the app, and give pgw a key to the same project.

## Before you begin

* A Google account for the [Firebase console](https://console.firebase.google.com).
* The app's package name, such as `com.example.phone`.

## Create the Firebase project and its key

**1. Create the Firebase project**

In the [Firebase console](https://console.firebase.google.com), create a project, and add an Android app with your package name.

**2. Download the app configuration**

Download `google-services.json` for the app build.

**3. Note the project ID and number**

In **Project settings**, on the **General** tab, note the project ID and the project number.

**4. Create a service account key**

On the **Service accounts** tab, choose **Generate new private key**, and save the JSON file.

> [!WARNING]
>
> The service account key is a credential. Don't commit it or share it.

## Register the Android app in pgw

Give pgw the project's ID, its number, and the key:

```bash theme={null}
pgw app create --platform android --bundle-id com.example.phone --fcm-project-id example-phone --fcm-project-number 123456789012 --fcm-service-account-file service-account.json
```

| Flag | Value |
| - | - |
| `--bundle-id` | The app's package name. |
| `--fcm-project-id` | The Firebase project ID, such as `example-phone`. Required. |
| `--fcm-project-number` | The Firebase project number, digits only. Optional. |
| `--fcm-service-account-file` | The service account key file. Required. |
| `--name` | Optional. A name that log lines show instead of the package name. |

Set the project number too, even though pgw doesn't require it. When an Android app registers, it names its Firebase project, and pgw uses that name to find the app record. Some apps send the ID and others send the number, so with both set, either one matches.

Each Android app needs its own Firebase project. pgw refuses a second Android app with the same project.

## Check that it works

Register the app through pgw, swipe it away, and call the account. The phone rings.

## If it doesn't work

| Symptom | Cause |
| - | - |
| The app's REGISTER gets `555 Push Notification Service Not Supported` | The app sent a Firebase project that no app record has. Usually the app sends the project number, and the record has only the ID. |
| The app registers, and no push arrives | The service account key belongs to another Firebase project than the one in the app's `google-services.json`. The [push log](https://docs.pgw.sipmicro.services/push-log.md) shows Google's answer. |
| Pushes arrive late or not at all after a few days | The app doesn't show a notification for each call push, so Android lowered its priority. |

## Which push pgw sends for each event

pgw sends every push as an FCM data message, which means that the app receives the data and decides what to show. pgw sends call and missed-call pushes with high priority, so that Android wakes the app at once. It sends refresh and test pushes with normal priority.

The app must show a notification for every high-priority message, because Android lowers the priority of an app that doesn't. For the fields of each push, see [Push payload](https://docs.pgw.sipmicro.services/reference/push-payload.md).

## Next steps

> [card] [Integrate your app](https://docs.pgw.sipmicro.services/apps/integrate.md)
>
> Send the push token in the REGISTER and show a notification for each call.

> [card] [Try it on the Android emulator](https://docs.pgw.sipmicro.services/tutorial-android-emulator.md)
>
> Test the Firebase setup with an open-source app before you change your own.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.