# Android notification channels

> The default channel Herald pushes use on Android, how to name and translate it, and how channels are chosen in the foreground and background.

On Android 8.0 and later, every notification belongs to a channel, and users control sound, vibration and visibility per channel in system settings. Herald pushes use the default channel unless a push variant names another.

## The default channel

| Property | Value |
|---|---|
| Channel ID | `herald_default` (`HeraldNotifications.DEFAULT_CHANNEL_ID`) |
| Name | The string resource `herald_default_channel_name`, "Notifications" by default |
| Importance | `NotificationManager.IMPORTANCE_DEFAULT`: makes a sound, shows in the status bar, no heads-up banner |
| Created | When you call `HeraldNotifications.createDefaultChannel`, or the first time `herald-fcm` shows a push |

Create it at startup, as the quickstart does, so the channel exists before the first push and users can adjust it in settings early.

## How a channel is chosen

| App state | Who shows the notification | Channel |
|---|---|---|
| Foreground | `herald-fcm` | The channel named in the push's `herald_channel_id` data key or FCM `channel_id`, if it exists on the device; otherwise `herald_default` |
| Background | Android and Firebase | The channel named in the push, otherwise the `default_notification_channel_id` in your manifest, otherwise Firebase's own fallback channel |

A Herald push uses the default channel unless its variant names a channel (see [The Android channel option](#the-android-channel-option)). Set the manifest default to `herald_default` so background and foreground pushes land in the same channel:

```xml
<meta-data
    android:name="com.google.firebase.messaging.default_notification_channel_id"
    android:value="herald_default" />
```

## The Android channel option

To send a push on one of your own channels, open the push variant with **Edit**, open **Delivery options (mobile SDK)** and enter the channel's ID in **Android channel ID** (up to 100 characters). Leave it empty to use the app's default channel. Choose **Save delivery options** to store it.

Herald sends the ID in the `herald_channel_id` data key and as the FCM `channel_id`. Create the channel in your app before the first push arrives, with `NotificationManager.createNotificationChannel`. If the channel does not exist on the device, the foreground rule above applies and the push lands in `herald_default`. The option applies to Android only and has no effect on iOS.

## Name, translate or change importance

Android fixes a channel's importance when it is created, and only the user can change it afterwards. Set the name and importance before the channel first exists.

To rename or translate the channel, override the string resource in your app:

```xml
<!-- res/values/strings.xml (add translations in res/values-es/strings.xml and so on) -->
<resources>
    <string name="herald_default_channel_name">Workout reminders</string>
</resources>
```

To set a different importance, pass it when you create the channel:

```kotlin
HeraldNotifications.createDefaultChannel(
    this,
    name = getString(R.string.herald_default_channel_name),
    importance = NotificationManager.IMPORTANCE_HIGH,
)
```

The call does nothing if the channel already exists. To change importance for existing installs, users have to change it in system settings.

## Edge cases

- **The user turns the channel off.** Android drops Herald pushes on that channel without showing them. The notification permission in device data still reports `authorized`, because the app-level switch is on.
- **The user turns all app notifications off.** `herald-fcm` shows nothing, and the next batch reports the notification permission as `denied`.

## Related

- [Android setup](/docs/push-notifications/android-setup)
- [Permission prompts](/docs/push-notifications/permission-prompts)
