Per creare un avviso basta usare il comando mobileCreateLocalNotification. Ad esempio creiamo uno stack così:
Adesso mettiamo il seguente codice nel pulsante invia (Send):
on mouseUp put the seconds into tCurrentTime put field "alertbody" into tAlertBody put field "alertbutton" into tAlertButton put field "message" into tAlertMessage put tCurrentTime + word 1 of field "seconds" into tNotificationTime put the hilite of button "sound" into tSound mobileCreateLocalNotification tAlertBody, tAlertButton, tAlertMessage, tNotificationTime, tSoundend mouseUp
In questo premendo il tasto invia si crea un avviso con il testo che abbiamo scritto nei vari campi.
Vi ricordo che la data e l'ora si imposta con il valore in UNIX time, cioè i secondi al primo Gennaio 1970. Nel codice si sfrutta the seconds vi dà già lo UNIX time attuale, a cu sommate i secondi che mancano alla data e ora dell'avviso.
Su Android appare un'icona di avviso in alto, mentre su iOS:
Per cancellare un avviso c'è il comando mobileCancelLocalNotification oppure mobileCancelAllLocalNotifications se volgiamo cancellare tutte le notifiche in sospeso.
Mentre quando appare la notifica, possiamo anche fare in modo che nella nostra app succeda qualcosa, usando il messaggio localNotificationReceived. Ad esempio:
on localNotificationReceived tMessage answer "Local Notification: " & quote & tMessage & quote with "Okay"end localNotificationReceived
Ecco ad esempio un messaggio di avviso:
Ma se usiamo uno switch, possiamo decidere a seconda del messaggio, possiamo decidere cosa fa la nostra app.



Nessun commento:
Posta un commento