Class Notifications
- java.lang.Object
-
- com.openfin.desktop.notifications.Notifications
-
public class Notifications extends Object
This class initializes and manages notifications.- Author:
- Anthony
-
-
Field Summary
Fields Modifier and Type Field Description static StringEVENT_TYPE_ACTIONstatic StringEVENT_TYPE_CLOSEDstatic StringEVENT_TYPE_CREATED
-
Constructor Summary
Constructors Constructor Description Notifications(DesktopConnection desktopConnection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddEventListener(String eventType, NotificationEventListener listener)Add a listener to handle specified notification events.CompletionStage<Boolean>clear(String id)Clears a specific notification from the Notification Center.CompletionStage<Integer>clearAll()Clears all Notifications which were created by the calling application, including child windows.CompletionStage<NotificationOptions>create(NotificationOptions options)Creates a new notification.CompletionStage<List<NotificationOptions>>getAll()Retrieves all Notifications which were created by the calling application, including child windows.CompletionStage<ProviderStatus>getProviderStatus()Get notification service provider status.booleanremoveEventListener(String eventType, NotificationEventListener listener)Removes a listener previously added with addEventListener.CompletionStage<Void>toggleNotificationCenter()Toggles the visibility of the Notification Center.
-
-
-
Field Detail
-
EVENT_TYPE_ACTION
public static final String EVENT_TYPE_ACTION
- See Also:
- Constant Field Values
-
EVENT_TYPE_CREATED
public static final String EVENT_TYPE_CREATED
- See Also:
- Constant Field Values
-
EVENT_TYPE_CLOSED
public static final String EVENT_TYPE_CLOSED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Notifications
public Notifications(DesktopConnection desktopConnection)
-
-
Method Detail
-
create
public CompletionStage<NotificationOptions> create(NotificationOptions options)
Creates a new notification. The notification will appear in the Notification Center and as a toast if the Center is not visible. If a notification is created with an id of an already existing notification, the existing notification will be recreated with the new content.- Parameters:
options- Notification configuration options.- Returns:
- new CompletionStage for the fully-hydrated NotificationOptions.
-
clear
public CompletionStage<Boolean> clear(String id)
Clears a specific notification from the Notification Center.- Parameters:
id- ID of the notification to clear.- Returns:
- new CompletionStage for the status, true if the notification was successfully cleared. false if the notification was not cleared, without errors.
-
clearAll
public CompletionStage<Integer> clearAll()
Clears all Notifications which were created by the calling application, including child windows.- Returns:
- new CompletionStage for the the number of successfully cleared Notifications.
-
getAll
public CompletionStage<List<NotificationOptions>> getAll()
Retrieves all Notifications which were created by the calling application, including child windows.- Returns:
- new CompletionStage for all NotificationOptions.
-
toggleNotificationCenter
public CompletionStage<Void> toggleNotificationCenter()
Toggles the visibility of the Notification Center.- Returns:
- new CompletionStage when the command is delivered.
-
addEventListener
public boolean addEventListener(String eventType, NotificationEventListener listener)
Add a listener to handle specified notification events.- Parameters:
eventType- EVENT_TYPE_ACTION, EVENT_TYPE_CREATED or EVENT_TYPE_CLOSED.listener- the event listener to be added.- Returns:
- true if the listener was added as a result of the call.
-
removeEventListener
public boolean removeEventListener(String eventType, NotificationEventListener listener)
Removes a listener previously added with addEventListener.- Parameters:
eventType- EVENT_TYPE_ACTION, EVENT_TYPE_CREATED or EVENT_TYPE_CLOSED.listener- the event listener to be removed.- Returns:
- true if the listener was removed as a result of the call.
-
getProviderStatus
public CompletionStage<ProviderStatus> getProviderStatus()
Get notification service provider status.- Returns:
- new CompletionStage for the ProviderStatus.
-
-