add script for notification in browser
Browse files- app/main.py +17 -0
app/main.py
CHANGED
|
@@ -138,10 +138,27 @@ def main(page: ft.Page):
|
|
| 138 |
page.theme_mode = ft.ThemeMode.DARK
|
| 139 |
page.padding = 10
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
def mostrar_notificacion(texto, color="blue"):
|
|
|
|
| 142 |
snack = ft.SnackBar(ft.Text(texto), bgcolor=color)
|
| 143 |
page.overlay.append(snack)
|
| 144 |
snack.open = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
page.update()
|
| 146 |
|
| 147 |
def enviar_telegram_con_botones(loan_id, mensaje):
|
|
|
|
| 138 |
page.theme_mode = ft.ThemeMode.DARK
|
| 139 |
page.padding = 10
|
| 140 |
|
| 141 |
+
# Solicitar permiso para notificaciones de navegador/sistema
|
| 142 |
+
try:
|
| 143 |
+
page.get_notification_permission()
|
| 144 |
+
except: pass
|
| 145 |
+
|
| 146 |
def mostrar_notificacion(texto, color="blue"):
|
| 147 |
+
# Notificación en la app (SnackBar)
|
| 148 |
snack = ft.SnackBar(ft.Text(texto), bgcolor=color)
|
| 149 |
page.overlay.append(snack)
|
| 150 |
snack.open = True
|
| 151 |
+
|
| 152 |
+
# Notificación de Sistema/Navegador
|
| 153 |
+
try:
|
| 154 |
+
# Intentamos lanzar notificación nativa si hay permiso
|
| 155 |
+
page.show_notification(
|
| 156 |
+
title="MAKER STATION",
|
| 157 |
+
body=texto,
|
| 158 |
+
icon="/icon192x192.png"
|
| 159 |
+
)
|
| 160 |
+
except: pass
|
| 161 |
+
|
| 162 |
page.update()
|
| 163 |
|
| 164 |
def enviar_telegram_con_botones(loan_id, mensaje):
|