Skip to content
Titanium SDK
Version13.3.0

You are reading 13.3.0. See this page in 13.4.1.

Titanium.UI.Notification

proxyAndroidsince 0.8

Extends Titanium.Proxy

A toast notification.

Android iOS
Android

A toast notification is an unobtrusive, pop-up notification that does not block the UI. Use the Titanium.UI.createNotification method or <Notification> Alloy element to create a Toast notification.

On Android, by default, a toast notification appears centered on the bottom half of the screen. On Windows Phone, by default, a toast notification appears over the status bar on the top part of the screen.

Examples

Simple Toast Notification

The simplest use case is also the most common.

var toast = Ti.UI.createNotification({
    message:"Please Stand By",
    duration: Ti.UI.NOTIFICATION_DURATION_LONG
});
toast.show();

Alloy XML Markup

Previous example as an Alloy view.

index.xml

<Alloy>
    <Window>
        <Notification id="toast" platform="android" message="Please Stand By" duration="Ti.UI.NOTIFICATION_DURATION_LONG" />
    </Window>
</Alloy>

index.js

$.index.open();
$.toast.show();

Properties 10

apiName

Stringsince Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0read-only

Inherited from Titanium.Proxy

The name of the API that this proxy corresponds to.

bubbleParent

Booleansince Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0

Inherited from Titanium.Proxy

Indicates if the proxy will bubble an event to its parent.

Default: true

gravity

Numbersince 5.4.0

Determines the location at which the notification should appear on the screen.

Accepts 27 constants

Horizontal placement of the notification, as a fraction of the screen width.

Useful values range from -0.5 (far left) to 0.5 (far right). A value of zero indicates default placement.

Default: 0

message

String

Notification text to display.

Vertical placement of the notification, as a fraction of the screen height.

Useful values range from -0.5 (top) to 0.5 (bottom). A value of zero indicates default placement.

Default: 0

xOffset

Number

X offset from the default position, in pixels.

Default: 0

yOffset

Number

Y offset from the default position, in pixels.

Default: 0

Methods 5

Inherited from Titanium.Proxy

Adds the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to invoke when the event is fired.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Inherited from Titanium.Proxy

Fires a synthesized event to any registered listeners.

Parameters
ParametersTypeDescription
nameString

Name of the event.

event?Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Inherited from Titanium.Proxy

Removes the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Show the notification.