Skip to main content

NotificationActionInput

Input collected when a notification action is selected.

Used by NotificationAction.input.

Note
  • Android supports reply choices, free-form text, and MIME-type hints. iOS/macOS use a text-input action; Windows uses a separate text box associated with the action ID. Linux and Web show the action as a regular button without an input.
  • On Android, a notification the user replied to that isn't dismissed shows a progress spinner until the app updates it. With NotificationAction.cancel_notification set to True, Android 15 and earlier dismiss it after the reply, so updating it posts a new notification that alerts again, while Android 16 and later keep it, spinning. To get the same result on every version, set cancel_notification to False, so no version dismisses it, and update the notification from Notifications.on_action:

    import flet as ft
    import flet_notifications as ftn

    reply = ftn.NotificationAction(
    id="reply",
    title="Reply",
    input=ftn.NotificationActionInput(label="Message"),
    cancel_notification=False,
    )


    async def handle_action(e: ftn.NotificationActionEvent):
    if (
    e.page.platform == ft.PagePlatform.ANDROID
    and e.action_id == "reply"
    and e.id is not None
    ):
    await notifications.show(
    id=e.id,
    title="Ada",
    body=f"You: {e.input}",
    payload=e.payload,
    options=ftn.NotificationOptions(
    android=ftn.AndroidOptions(
    # Doesn't alert again for the update.
    only_alert_once=True,
    # Removes it after a second; leave out to keep it.
    # Cancelling right after the update can be refused.
    timeout_after=ft.Duration(seconds=1),
    )
    ),
    )

Properties

Properties​

allow_free_formclass-attributeinstance-attribute​

allow_free_form: bool = True

Whether to allow the user to type an arbitrary reply.

Set to False with choices to restrict replies to suggestions.

Note

Supported only on Android. Reply inputs on iOS, macOS, and Windows allow free-form text.

allowed_mime_typesclass-attributeinstance-attribute​

allowed_mime_types: list[str] = field(default_factory=list)

Accepted reply MIME types, such as "image/png".

An empty list requests no MIME-type-specific input.

Note

The event model exposes text responses, not a dedicated attachment-result field. MIME-type filtering is supported only on Android.

choicesclass-attributeinstance-attribute​

choices: list[str] = field(default_factory=list)

Suggested reply strings.

An empty list provides no predefined choices.

Note

Supported only on Android.

labelclass-attributeinstance-attribute​

label: str | None = None

User-visible label describing the input.

Note

On Android, labels the reply input. On iOS/macOS, supplies the text-input button title and placeholder; None uses the action title for the button. On Windows, supplies the text box title and placeholder.