Notification is a script for Appcelerator Titanium Mobile. It allows you to display a modal, visual, notification on screen for multiple purposes.
Include Notification.js in your document: Ti.include('path/to/Notification.js');
To use Notification just call the method: Notification.show(...);
Notification.show(...) needs a parameters dictionary with the following values.
parent: The container where the notification will be shown
label (optional): The text displayed on the notification
spinner (optional): Shows an ActivityIndicator with the notification
image (optional): The url to the image that will be shown with the notification
duration (optional): Seconds before the notification will hide itself
onclick (optional): A method to call when a tap is detected on the notification
Notification.show({
parent: win,
label: 'Loading...',
spinner: true,
onclick: function ( ) {
alert('Loading canceled!');
}
});
Notification.hide(...) removes a notification from the screen.
Notification.hide({ parent: win });
Notification.setLabel('Some text') changes the label of a notification.
Notification.setDefaults(...) sets default values to be used for all notifications. They are saved in NSDefaults, and can be overrided when specifying other values in Notification.show(...). You can reset the configuration by calling this method without any parameter.
Notification.setDefaults({ size: 150, label: L('Please wait...'), spinner: true });