Back

CreateNotification

Hello World
Content:
- Methods

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

ntf = app.CreateNotification( options ) → app object: Notification

The “AutoCancel” option will automatically dismiss the notificatin if the user touches it. “FullScreen” tries to create a larger notification on the screen. And “OnGoing” makes the Notification closeable by your app only.

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 - Notification

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      

Methods

The following methods are available on the Notification object:

Cancel( id )
GetType() → string: “Notification”
Notify( id )
string
number: milliseconds
string:
  hexadecimal: “#rrggbb”, “#aarrggbb”
  colourName: “red”, “green”, ...
string: path to file or folder ( “/absolute/...” or “relative/...” )
string: comma “,” separated: “Ongoing”, “AutoCancel”, “FullScreen”
ntf.Cancel
Cancel a notification with a specific id.
ntf.GetType
Returns the control class name.
ntf.Notify
Send the notification to the user.
ntf.SetLargeImage
Set an image which will be displayed bigger than usual.
ntf.SetLights
Activate the device notification LEDs.
ntf.SetMessage
Set notification texts.
ntf.SetSmallImage
Set a small image in your notification.