You are reading 13.4.0. See this page in 13.4.1.
Titanium.UI.Notification
Extends Titanium.Proxy
A toast notification.
| Android | iOS |
|---|---|
![]() |
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
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
Inherited from Titanium.Proxy
Indicates if the proxy will bubble an event to its parent.
Default: true
duration
NumberDetermines how long the notification stays on screen.
Default: <Titanium.UI.NOTIFICATION_DURATION_SHORT>
Determines the location at which the notification should appear on the screen.
Accepts 27 constants
- GRAVITY_AXIS_CLIP
- GRAVITY_AXIS_PULL_AFTER
- GRAVITY_AXIS_PULL_BEFORE
- GRAVITY_AXIS_SPECIFIED
- GRAVITY_AXIS_X_SHIFT
- GRAVITY_AXIS_Y_SHIFT
- GRAVITY_BOTTOM
- GRAVITY_CENTER
- GRAVITY_CENTER_HORIZONTAL
- GRAVITY_CENTER_VERTICAL
- GRAVITY_CLIP_HORIZONTAL
- GRAVITY_CLIP_VERTICAL
- GRAVITY_DISPLAY_CLIP_HORIZONTAL
- GRAVITY_DISPLAY_CLIP_VERTICAL
- GRAVITY_END
- GRAVITY_FILL
- GRAVITY_FILL_HORIZONTAL
- GRAVITY_FILL_VERTICAL
- GRAVITY_HORIZONTAL_GRAVITY_MASK
- GRAVITY_LEFT
- GRAVITY_NO_GRAVITY
- GRAVITY_RELATIVE_HORIZONTAL_GRAVITY_MASK
- GRAVITY_RELATIVE_LAYOUT_DIRECTION
- GRAVITY_RIGHT
- GRAVITY_START
- GRAVITY_TOP
- GRAVITY_VERTICAL_GRAVITY_MASK
horizontalMargin
NumberHorizontal 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
Inherited from Titanium.Proxy
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
message
StringNotification text to display.
verticalMargin
NumberVertical 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
NumberX offset from the default position, in pixels.
Default: 0
yOffset
NumberY 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 | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to invoke when the event is fired. 4 fields
|
applyProperties
since 3.0.0Inherited from Titanium.Proxy
Applies the properties to the proxy.
| Parameters | Type | Description |
|---|---|---|
| props | Dictionary | A dictionary of properties to apply. |
Inherited from Titanium.Proxy
Fires a synthesized event to any registered listeners.
| Parameters | Type | Description |
|---|---|---|
| name | String | 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 | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to remove. Must be the same function passed to 4 fields
|
Show the notification.
