Skip to content

Instantly share code, notes, and snippets.

@pec1985
Last active January 1, 2016 18:58
Show Gist options
  • Save pec1985/7fd403846a7887c9f5f0 to your computer and use it in GitHub Desktop.
Save pec1985/7fd403846a7887c9f5f0 to your computer and use it in GitHub Desktop.
Ti.BlackBerry.Toast

Blackberry 10 Toast Notification

Description:

Brief:

A message displayed to the user that does not usually require user interaction to be dismissed

Details

The toast will be dismissed after a predefined timeout period lapses (around 3 seconds). If the toast includes a button, then the timeout period is activated with the first user interaction, for example, user touching the screen. During this time, if a button is displayed, the user can select it.

Properties:

  • buttonTitle - String
    • String representing the title of the button
    • No button will show if left empty
  • icon - String
    • String with the path of the icon for the toast.
    • No icon will show if left empty
  • message - String
    • Toast message body of the notification
  • position - Constant Number
    • Vertical position of the toast.
    • Use any of the following:
      • Ti.BlackBerry.POSITION_TYPE_MIDDLE_CENTER
      • Ti.BlackBerry.POSITION_TYPE_TOP_CENTER
      • Ti.BlackBerry.POSITION_TYPE_BOTTOM_CENTER
    • Defaults to Ti.BlackBerry.POSITION_TYPE_MIDDLE_CENTER if not specified
  • modality - Constant Number
    • Sets the modality for the toast.
    • Use any of the following (Elevated permissions are required to use global modality)
      • Ti.BlackBerry.MODALITY_APPLICATION
      • Ti.BlackBerry.MODALITY_GLOBAL
    • Defaults to Ti.BlackBerry.MODALITY_APPLICATION if not specified

Methods

  • show()
    • Display's the toast on the screen
  • cancel()
    • Dismisses the toast when called.

Events

  • finish
    • Fires when the toast dismisses.
    • Event properties:
      • result description of how the toast was dismissed
      • type event name: finish
      • source the proxy

Usage:

var toast = Ti.BlackBerry.createToast({
	buttonTitle: 'Ok',
	message: 'This is a cool toast!',
	position: Ti.BlackBerry.POSITION_TYPE_TOP_CENTER,
});
toast.show();
toast.addEventListener('finish', function(e) {
	Ti.API.info(JSON.stringify(e));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment