Back

Notification

The Notification object can be used to put messages in the notification drawer.

Create a Notification object using the CreateNotification method of the app object:

 notify = app.CreateNotification( options );

options can include "AutoCancel", "FullScreen" and "Ongoing"

Use the SetMessage method to tell the object what to display

 notify.SetMessage( ticker, title, text );

The Notify method tells it to send the notification

 notify.Notify( id );

When the user touches your notification, your app will come to the front, even if it was not running.

If you use more than one notification, app.GetNotifyId() can be used to check which notification was pressed by the user.

Example


function OnStart()
{
    app.ShowPopup("Sending notification");
    notify = app.CreateNotification();
    notify.SetMessage("Ticker","Title","Text");
    notify.Notify("testID");
    setTimeout(cancel,5000);
}

function cancel()
{
    notify.Cancel("testID");
    app.ShowPopup("Notification cancelled");
}
    Copy     Copy All      Run     

See 'CreateNotification for more informations and a complete function list