Tâche Show Notification
Résumé
- Nom interne :
ShowNotification - Catégorie : Notifications
- Objectif : Afficher une notification système avec un titre et un message. Réutiliser le même ID pour mettre à jour ou remplacer une notification existante.
- Type de tâche : Normale
Compatibilité
-
Version AndroMate minimale :
1.1.0 -
Version AndroMate maximale :
1.1.0 -
Android minimum :
Android 13 (API 33) -
Android testé maximum :
Android 16 (API 36) -
Permissions requises :
POST_NOTIFICATIONS
Description détaillée
La tâche Show Notification poste une notification dans la barre système sur un canal dédié (andromate_workflow_notifications). Le message est affiché avec BigTextStyle, donc le contenu long est montré en entier.
La tâche fonctionne en arrière-plan (foreground service) — les notifications sont faites pour ça. Sur Android 13+ (API 33), la permission runtime POST_NOTIFICATIONS doit être accordée ; sinon la tâche lève NOTIFICATION-TASK-001.
Paramètres d'entrée
| Paramètre | Type | Requis | Valeurs possibles / Règles | Compatibilité Android | Compatibilité AndroMate | Défaut |
|---|---|---|---|---|---|---|
title_text |
String | Oui | Titre de la notification (interpolation supportée) | Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | "" |
message |
String | Oui | Corps de la notification (interpolation supportée) | Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | "" |
notification_id |
Integer | Non | Réutiliser le même ID pour mettre à jour/remplacer | Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | 0 (auto) |
Paramètres de sortie
Cette tâche ne produit aucune variable de sortie. Elle retourne un VoidResult en cas de succès.
Exceptions
| Code | Condition de déclenchement |
|---|---|
NOTIFICATION-TASK-001 |
Permission POST_NOTIFICATIONS non accordée (Android 13+) |
Diagramme d'exécution
flowchart TD
Start([▶ ShowNotification]) --> Resolve[🔧 Résolution titre & message]
Resolve --> Channel[📡 Création du canal]
Channel --> Build[🔔 Construction notification\nBigTextStyle]
Build --> Post{Permission accordée ?}
Post -->|Non| Throw([❌ NOTIFICATION-TASK-001])
Post -->|Oui| Notify[📬 NotificationManager.notify]
Notify --> Success([✅ VoidResult])
style Start fill:#e3f2fd
style Success fill:#c8e6c9
style Throw fill:#ffcdd2
style Build fill:#fff9c4
style Notify fill:#c8e6c9
Fonctionnement :
- Résolution :
title_textetmessagesont résolus avec le contexte AndroMate - Canal : le canal de notification est créé (idempotent)
- Construction : la notification est construite avec
BigTextStyle - Post :
NotificationManager.notify(id, ...)— lèveNOTIFICATION-TASK-001si la permission manque - Résultat : retourne
VoidResult
Exemples de code
Exemple 1 — Notifier la fin d'un workflow
{
"ShowNotification": [
{
"id": "1",
"title": "Notifier fin",
"title_text": "Workflow terminé",
"message": "Le job $job_name s'est terminé avec succès"
}
]
}
Exemple 2 — Mettre à jour la même notification (ID fixe)
{
"ShowNotification": [
{
"id": "2",
"title": "Notification de progression",
"title_text": "Progression",
"message": "Étape 2 / 5 terminée",
"notification_id": 42
}
]
}
Détails des paramètres d'entrée
title_text — Titre de la notification
La ligne de titre (en gras) de la notification. Supporte l'interpolation $variable et ${SPECIAL_VAR}.
message — Corps de la notification
Le texte du corps. Les longs messages sont affichés en entier grâce à BigTextStyle.
notification_id — ID de la notification
Optionnel. Si une valeur positive est fournie, la notification réutilise cet ID (un nouvel appel avec le même ID met à jour/remplace l'existante). Si vide ou 0, un ID unique est généré (nouvelle notification à chaque appel).
Détails des paramètres de sortie
Cette tâche ne produit aucune variable de sortie.