Skip to main content

Android notification channels

Android groups notifications into channels that users control individually in system settings (sound, importance, vibration). notification-kit exposes channel management that is a no-op on non-Android platforms, so you can call these methods unconditionally.

Create a channel

import { notifications } from 'notification-kit';
import { NotificationKit } from 'notification-kit';

await NotificationKit.getInstance().createChannel({
id: 'reminders',
name: 'Reminders',
description: 'Scheduled reminders and check-ins',
importance: 4, // 1 (min) … 5 (max)
visibility: 1, // -1 secret, 0 private, 1 public
sound: 'default',
vibration: true,
lights: true,
lightColor: '#4f46e5',
showBadge: true,
});

NotificationChannel

FieldTypeNotes
idstringRequired, stable identifier.
namestringRequired, shown to users.
descriptionstringShown in system settings.
importance1 | 2 | 3 | 4 | 5Higher = more intrusive.
visibility-1 | 0 | 1Lock-screen visibility.
soundstring'default', 'none', or a resource name.
vibrationboolean | number[]On/off or a pattern.
lightsbooleanLED notification light.
lightColorstringLED color.
showBadgebooleanAllow app-icon badge.
groupstringChannel group id.

List and delete

const channels = await NotificationKit.getInstance().listChannels();
await NotificationKit.getInstance().deleteChannel('reminders');

On non-Android platforms listChannels() returns [] and createChannel / deleteChannel resolve without doing anything.

Posting to a channel

Reference the channel id when scheduling a local notification:

await notifications.schedule({
id: 10,
title: 'Daily check-in',
body: 'How are you today?',
channelId: 'reminders',
schedule: { on: { hour: 9, minute: 0 }, every: 'day' },
});

Events

Channel changes emit events you can observe:

notifications.on('channelCreated', (e) => console.log(e.channel));
notifications.on('channelDeleted', (e) => console.log(e.channelId));

Android 13+ permission

On Android 13 and later you still need the POST_NOTIFICATIONS runtime permission before any notification (channelled or not) is shown. See the Android setup page.