Class sap.ushell.services.NotificationsModule: sap/ushell/services/Notifications


A UShell service for fetching user notification data from the Notification center/service
and exposing them to the Unified Shell and Fiori applications UI controls.

In order to get user notifications, Unified Shell notification service issues OData requests
to the service defined by the configuration property serviceUrl,
for example: "/sap/opu/odata4/iwngw/notification/default/iwngw/notification_srv/0001"
.

Unified Shell Notification service has several working modes, depending on the environment and the available resources:
PackagedApp mode: Fiori launchpad runs in the context of PackagedApp
FioriClient mode: Fiori launchpad runs in the context of FioriLaunchpad
WebSocket mode: Fiori launchpad runs in a browser, and WebSocket connection to the notifications provider is available
Polling mode: Fiori launchpad in runs in a browser, and WebSocket connection to the notifications provider is not available

The notification service exposes an API that includes: - Service enabling and initialization
- Registration of callback functions (by Shell/FLP controls) that will be called for every data update
. - Retrieval of notification data (e.g. notifications, number of unseen notifications) - Execution of a notification actions - Marking user notifications as seen


Since: 1.32.0.
Constructor Summary
new sap.ushell.services.Notifications(oContainerInterface, sParameter, oServiceProperties)
Method Summary
dismissNotification(sNotificationId)Launches dismiss notification call.
executeBulkAction(sNotificationId, sActionId)Launches a notification action oData call.
getNotifications()Returns the notifications of the user
getNotificationsByTypeWithGroupHeaders()Returns the notifications of the user sorted by type include the group headers and the notifications
getUnseenNotificationsCount()Returns the number of unseen notifications
e.g.
init()Initializes the notification service

Initialization is performed only if the following two conditions are fulfilled:
1.

isEnabled()Indicates whether notification service is enabled.
isFirstDataLoaded()Return whether first request was already performed and data was returned.
markRead(sNotificationId)Launches mark as read notification call.
notificationsSeen()Mark all notifications as seen.
registerNotificationCountUpdateCallback(The)Gets a callback function that will be called when updated unseen notifications count is available.
registerNotificationsUpdateCallback(The)Gets a callback function that will be called when updated notifications data is available.
Constructor Detail
new sap.ushell.services.Notifications(oContainerInterface, sParameter, oServiceProperties)
Parameters:
{object}oContainerInterface The interface provided by the container
{object}sParameter Not used in this service
{object}oServiceProperties Service configuration
See:
sap.ushell.services.Container#getService
Method Detail
dismissNotification(sNotificationId)
Launches dismiss notification call.
Parameters:
{object}sNotificationId The ID of the notification whose action is being executed
Since:
1.34
executeBulkAction(sNotificationId, sActionId)
Launches a notification action oData call.

After launching the action, the function gets updated notification data in order to push the updated data to the consumers.

Parameters:
{object}sNotificationId The ID of the notification whose action is being executed
{object}sActionId The ID of the action that is being executed
Since:
1.32
getNotifications(): promise
Returns the notifications of the user
Since:
1.32
Returns:
{promise} Promise object that on success - returns all notification items
getNotificationsByTypeWithGroupHeaders(): promise
Returns the notifications of the user sorted by type include the group headers and the notifications
Since:
1.38
Returns:
{promise} Promise object that on success - returns all notification items
getUnseenNotificationsCount(): promise
Returns the number of unseen notifications
e.g. Notifications that the user hasn't seen yet.
Since:
1.32
Returns:
{promise} Promise object that on success - returns the number of unread notifications of the user
init()
Initializes the notification service

Initialization is performed only if the following two conditions are fulfilled:
1. Notification service is enabled
2. Notification service hasn't been initialized yet

The main initialization functionality is determining and setting the mode in which notifications are consumed.
The possible modes are:
PACKAGED_APP - Notifications are fetched when a callback is called by PackagedApp environment
FIORI_CLIENT - Notifications are fetched when a callback is called by FioriClient environment
WEB_SOCKET - Notifications are fetched on WebSocket "ping"
POLLING - Notifications are fetched using periodic polling mechanism

Since:
1.32
isEnabled(): boolean
Indicates whether notification service is enabled.
Enabling is based on the enable service configuration flag.
The service configuration must also include serviceUrl attribute.
Since:
1.32.0
Returns:
{boolean} A boolean value indicating whether the notifications service is enabled
isFirstDataLoaded()
Return whether first request was already performed and data was returned.
Since:
1.38
markRead(sNotificationId)
Launches mark as read notification call.

After launching the action, the function gets updated notification data in order to push the updated data to the consumers.

Parameters:
{object}sNotificationId The ID of the notification whose action is being executed
Since:
1.34
notificationsSeen()
Mark all notifications as seen.
the main use-case is when the user navigated to the notification center and sees all the pending notifications.
Since:
1.32
registerNotificationCountUpdateCallback(The)
Gets a callback function that will be called when updated unseen notifications count is available.
Parameters:
{object}The callback function that is registered and called on data update.
Since:
1.32
registerNotificationsUpdateCallback(The)
Gets a callback function that will be called when updated notifications data is available.
Parameters:
{object}The callback function that is registered and called on data update.
Since:
1.32