public class

Notification

extends Object
java.lang.Object
   ↳ com.neomades.notification.Notification
Known Direct Subclasses

Class Overview

A notification is a graphical object that presents notifications: information that an application can schedule for presentation at a specific date. The notifications are triggered by a NotificationManager for local notification or can be built from a PushMessage for push notifications.

Notification graphical interface depends of the platform, lot of options are only available for some specific platforms. However, the main information, the notification text (setText(String)), is available everywhere, be sure to use it when displaying the notification content.

Most of the time, clicking on a notification will automatically open the application. Transition between notification to application will result to a call to onLocalNotificationReceived(Notification). Use this method to do specific behavior between the transition notification - application.

Cross Platform Considerations

  • In Android, the Notification is a android.app.Notification. Notifications will appear in the status bar.
  • In iOS, the Notification is a UILocalNotification. The notification is displayed in the status bar. A notification is not displayed if the application that owns is opened.

Summary

Public Constructors
Notification()
Creates a new empty Notification.
Public Methods
String getExtras()
Returns the notification extra.
int getId()
Returns the notification identifier.
String getText()
Returns the notification description text.
String getTitle()
Returns the notification title.
Notification setAccessoryIcon(int accessoryIcon)
Sets the notification icon displayed in the status bar.
Notification setAccessoryIcon(Image accessoryIcon)
Sets the notification icon displayed in the status bar.
Notification setAutoCancel(boolean on)
Sets whether the notification should be removed in the phone status bar when the end-user has clicked to the notification.
Notification setBadge(int badge)
Sets the badge number inside the Application icon (iOS).
Notification setDate(Date date)
Sets a date to display in the notification.
Notification setExtras(String extras)
Sets extra information embedded into this notification.
Notification setIcon(Image icon)
Set a large icon that is shown on the right in the notification (optional).
Notification setIcon(int icon)
Set a large icon that is shown on the right in the notification (optional).
Notification setId(int id)
Sets an identifier/tag to this element
Notification setLED(Color color, int onMs, int offMs)
Sets the Color that you would like the LED on the device to blink, as well as the rate.
Notification setLaunchImage(int launchImage)
Sets an image to display when launching an application from the notification, during the application loading.
Notification setSound(int sound)
Sets a sound to play when the notification is displayed.
Notification setSubText(String subText)
Sets a subtitle for Android notification.
Notification setText(String string)
Sets the details text of this notification.
Notification setText(int text)
Sets the details text of this notification.
Notification setTitle(int title)
Sets the title of this notification.
Notification setTitle(String title)
Sets the title of this notification.
Notification setVibration(long[] vibrations)
Sets a vibration pattern to use when the notification appears.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Notification ()

Creates a new empty Notification.

Public Methods

public String getExtras ()

Returns the notification extra.

Returns
  • the notification extra

public int getId ()

Returns the notification identifier.

Returns
  • the identifier of this view
See Also

public String getText ()

Returns the notification description text.

Returns
  • the notification description text

public String getTitle ()

Returns the notification title. Default is the name of the application.

Returns
  • the notification title

public Notification setAccessoryIcon (int accessoryIcon)

Sets the notification icon displayed in the status bar.
If no image is set, the icon of the application will be used.

Limitations

Only available on Android.

Parameters
accessoryIcon must be an image from the resources
Returns
  • the current notification
See Also

public Notification setAccessoryIcon (Image accessoryIcon)

Sets the notification icon displayed in the status bar.
If no image is set, the icon of the application will be used.

Limitations

Only available on Android.

Parameters
accessoryIcon must be an image from the resources
Returns
  • the current notification

public Notification setAutoCancel (boolean on)

Sets whether the notification should be removed in the phone status bar when the end-user has clicked to the notification.

Cross Platform Considerations

Only available for android.

Parameters
on true if the notification should disappear in the status bar
Returns
  • the current notification

public Notification setBadge (int badge)

Sets the badge number inside the Application icon (iOS).

Parameters
badge the badge number (positive value to show the number, 0 or negative to hide it)
Returns
  • the current notification

public Notification setDate (Date date)

Sets a date to display in the notification.

Limitations

In iOS, the date must be the date at which the notification was sent and it cannot be changed.

Parameters
date a date to show in the notification
Returns
  • the current notification

public Notification setExtras (String extras)

Sets extra information embedded into this notification.

Parameters
extras extra information
Returns
  • the current notification

public Notification setIcon (Image icon)

Set a large icon that is shown on the right in the notification (optional).

Limitations

Only available on Android.

Parameters
icon must be an image from the resources
Returns
  • the current notification

public Notification setIcon (int icon)

Set a large icon that is shown on the right in the notification (optional).

Limitations

Only available on Android.

Parameters
icon must be an image from the resources
Returns
  • the current notification
See Also

public Notification setId (int id)

Sets an identifier/tag to this element

Parameters
id the identifier
Returns
  • the current notification

public Notification setLED (Color color, int onMs, int offMs)

Sets the Color that you would like the LED on the device to blink, as well as the rate. The rate is set in millisecond, the first parameter indicate the time for which the LED is on, the second the time for which the LED is off. The hardware will do its best to match the blinking pattern.

Limitations

Only available on Android

Parameters
color the color of the LED when on
onMs the time for the LED to be on
offMs the time for the LED to be off
Returns
  • the current notification
See Also

public Notification setLaunchImage (int launchImage)

Sets an image to display when launching an application from the notification, during the application loading.

Limitations

Only available on iOS.

Parameters
launchImage an image from the resources to display as the launch image
Returns
  • the current notification
See Also

public Notification setSound (int sound)

Sets a sound to play when the notification is displayed. It will replace the default platform sound.

Limitations

In Android, setting a sound has no effect.

Parameters
sound a sound from the resources to play when the notification is displayed
Returns
  • the current notification
See Also

public Notification setSubText (String subText)

Sets a subtitle for Android notification.

Cross Platform Considerations

Only available for android.

Parameters
subText a text
Returns
  • the current notification

public Notification setText (String string)

Sets the details text of this notification.

Parameters
string the message displayed in the notification
Returns
  • the current notification

public Notification setText (int text)

Sets the details text of this notification.

Parameters
text string from resource to display in the notification
Returns
  • the current notification
See Also
  • ResManager#getString(int)

public Notification setTitle (int title)

Sets the title of this notification.

Limitations

In iOS, even if the title is changed, the title displayed in the notification will be the application name. However, if getTitle() is used later on the code and a title was set, it is the title you set that will be returned.

Parameters
title title from resources
Returns
  • the current notification
See Also
  • ResManager#getString(int)

public Notification setTitle (String title)

Sets the title of this notification.

Limitations

In iOS, even if the title is changed, the title displayed in the notification will be the application name. However, if getTitle() is used later on the code and a title was set, it is the title you set that will be returned.

Parameters
title the title of the notification
Returns
  • the current notification

public Notification setVibration (long[] vibrations)

Sets a vibration pattern to use when the notification appears. It is an array of long where the first value indicates the number of milliseconds to wait before turning the vibrator on and the next value indicates the number of milliseconds for which to keep the vibrator on before turning it off. The hardware will do its best to match the vibration pattern.

This method requires the caller to hold the permission VIBRATE.

Limitations

Only available on Android

Parameters
vibrations an array of longs of times for which to turn the vibrator on or off.
Returns
  • the current notification