# Titanium.UI.Notification

A toast notification.

Availability
0.8
4.1.0

# Overview

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

# duration

Availability
0.8
4.1.0
duration :Number

Determines how long the notification stays on screen.

Default: Titanium.UI.NOTIFICATION_DURATION_SHORT


# gravity

Availability
5.4.0
gravity :Number

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


# horizontalMargin

Availability
0.8
horizontalMargin :Number

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

Availability
0.8
4.1.0
message :String

Notification text to display.


# verticalMargin

Availability
0.8
verticalMargin :Number

Vertical placement of the notifcation, 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

Availability
0.8
xOffset :Number

X offset from the default position, in pixels.

Default: 0


# yOffset

Availability
0.8
yOffset :Number

Y offset from the default position, in pixels.

Default: 0

# Methods

# show

Availability
0.8
4.1.0
show() void

Show the notification.

Returns

Type
void