NotificationChannel
Android notification channel grouping notifications with shared behavior.
Pass it as AndroidOptions.channel to create the channel
when a notification is first posted to it, or create it upfront with
Notifications.create_channel and pass
its id instead. Users manage channel preferences independently in Android
settings. Sound, vibration, lights, and importance cannot be reset by posting
another notification or recreating the same channel; use a new ID for a different
configuration.
Channels exist on Android 8.0+. On earlier versions, the channel's sound, vibration, lights, and importance apply to each notification posted with it.
Properties
audio_attributes_usage- Intended use of the channel's sound.bypass_dnd- Whether the channel should attempt to bypass Do Not Disturb.description- User-visible explanation of the notifications delivered through this channel.enable_lights- Whether to use the notification LED on supported devices.enable_vibration- Whether notifications in the channel vibrate.group_id- ID of the notification-channel group containing this channel.id- Nonempty, stable channel identifier used when posting notifications.importance- Initial channel importance.led_color- LED color used whenenable_lightsis enabled.name- Nonempty, user-visible channel name displayed in Android settings.play_sound- Whether notifications in the channel play sound.show_badge- Whether notifications may contribute launcher badges.sound- Sound resource name orcontent:///file://URI on the Android device.vibration_pattern- Alternating delay and vibration durations, in milliseconds.
Properties
audio_attributes_usageclass-attributeinstance-attribute
audio_attributes_usage: AndroidAudioAttributesUsage = (
AndroidAudioAttributesUsage.NOTIFICATION
)Intended use of the channel's sound.
Helps Android select audio routing, volume, and interruption policies. It does not
enable sound when play_sound is False or grant access to bypass Do Not
Disturb.
Fixed at channel creation.
bypass_dndclass-attributeinstance-attribute
bypass_dnd: bool = FalseWhether the channel should attempt to bypass Do Not Disturb.
Obtain notification-policy access with
Notifications.request_notification_policy_access
before creating the channel; otherwise Android ignores the request.
Bypassing Do Not Disturb doesn't override the device's silent or vibrate
mode.
descriptionclass-attributeinstance-attribute
description: str | None = NoneUser-visible explanation of the notifications delivered through this channel.
None shows no description.
enable_lightsclass-attributeinstance-attribute
enable_lights: bool = FalseWhether to use the notification LED on supported devices.
Fixed at channel creation.
enable_vibrationclass-attributeinstance-attribute
enable_vibration: bool = TrueWhether notifications in the channel vibrate.
Requires the Android VIBRATE permission. Fixed at channel creation.
group_idclass-attributeinstance-attribute
group_id: str | None = NoneID of the notification-channel group containing this channel.
Create the group first with
Notifications.create_channel_group.
This organizes channels in settings; it does not group notifications in the tray.
importanceclass-attributeinstance-attribute
importance: AndroidImportance = AndroidImportance.DEFAULTInitial channel importance.
The user can change it after creation. See
AndroidImportance for the interruption behavior of each
level.
led_colorclass-attributeinstance-attribute
led_color: ColorValue | None = NoneLED color used when enable_lights is enabled.
Accepts concrete Flet color names and hexadecimal colors. Theme-dependent colors cannot be resolved by this headless service. Fixed at channel creation.
play_soundclass-attributeinstance-attribute
play_sound: bool = TrueWhether notifications in the channel play sound.
Fixed at channel creation. Use sound to choose a custom sound.
show_badgeclass-attributeinstance-attribute
show_badge: bool = TrueWhether notifications may contribute launcher badges.
Requires support from the launcher and is subject to user settings.
soundclass-attributeinstance-attribute
sound: str | None = NoneSound resource name or content:// / file:// URI on the Android device.
A raw resource name, such as "alert", refers to a file in the app's
res/raw resources and omits the file extension. Add the file with the
res_dir build setting,
for example as raw/alert.mp3.
Requires play_sound. None uses the default notification sound.
Fixed at channel creation; changing this value does not replace an existing
channel's sound.
A file:// URI of a file in the app's private storage is stored but not
played, because the system cannot read the file.
vibration_patternclass-attributeinstance-attribute
vibration_pattern: list[int] | None = NoneAlternating delay and vibration durations, in milliseconds.
For example, [0, 200, 100, 200] starts immediately and vibrates twice.
Requires enable_vibration; fixed at channel creation.