Toast

The Toast object contains functions for displaying toast notifications.

The functionality of this object allows the developer to display system toast notifications within their WebWorks application.


Supported Platform(s)

- BlackBerry 10
View Supported Platform Table
APIBB5.0BB6.0BB7.0PB1.0PB2.0BB10Ripple
blackberry.ui.toast.show           Y 

Configuration Document Settings

To use all of the API described for this object, you must ensure the following settings are in your configuration document:

You must declare the feature element(s) below in your configuration document:

Feature IDBB5.0BB6.0BB7.0PB1.0PB2.0BB10Ripple
<feature id="blackberry.ui.toast" />           Y 

Permission Elements (PlayBook and BlackBerry 10+)
This API does not require a <permission> element to be declared in the configuration document of your BlackBerry WebWorks Application.

Functions

Functions

static Number blackberry.ui.toast.show (message : String, [options : Object])


Displays a toast notification.


Supported Platforms
 - BlackBerry 10


Parameters
message Message to be displayed in the toast.
options An optional options object that specifies the buttonText, and callback handlers that should be used by the toast

buttonText: Optional parameter that specifies the label for the button within the toast.
buttonCallback: Optional callback for receiving the button event when the user selects the toast button.
dismissCallback: Optional callback for receiving an event when the toast dismisses either through the toast's timeout or when the button is selected.

Return:

A numeric ID to reference this toast by.



Code Example:
<script type="text/javascript">

function showCustomToast() {
   var message = "This is my toast!",
       buttonText = "Click Me",
       toastId,
       onButtonSelected = function () {
          console.log('Button was clicked for toast: ' + toastId);
       },
       onToastDismissed = function () {
          console.log('Toast disappeared: ' + toastId);
       },
       options = {
         buttonText : buttonText,
         dissmissCallback : onToastDismissed,
         buttonCallback : onButtonSelected
       };

   toastId = blackberry.ui.toast.show(message, options);
}

</script>
Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 30 2012 18:15:45 GMT-0500 (EST)