Listen to close event of the notification
Here's a Typescript example to listen to the close notification. Below code contains code to listen close action of already opened notification with id notificationId007:
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID', 'v1');
let notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId007');
const requestObject:IEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnNotificationCloseActionEvent') as IEventRequest;
notificationContext.subscribe(requestObject, (response) => {
const resp: INotificationCloseActionEventResponse = response as INotificationCloseActionEventResponse;
console.log(resp.getResponseData().getNotificationId())
});
Here's a Typescript example. The first part is to open a notification with id,
notificationId007. Once it's opened and the result succeeds, we can add the code to
listen to the close notification:
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID', 'v1');
let notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId007');
const requestObject: IShowNotificationRequest = frameworkProvider.requestHelper.createPublishRequest('ShowNotification') as IShowNotificationRequest;
requestObject.setTitle('title');
requestObject.setSummary('Error message summary');
notificationContext.publish(requestObject).then((message) => {
const response: INotificationOperationResponse = message as INotificationOperationResponse;
//given below is the code to listen to close notification of this notification
const requestObject:IEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnNotificationCloseActionEvent') as IEventRequest;
notificationContext.subscribe(requestObject, (response) => {
const resp: INotificationCloseActionEventResponse = response as INotificationCloseActionEventResponse;
console.log(resp.getResponseData().getNotificationId())
});
});
Here's a JavaScript example of listening to the close notification. The following code
shows an example of listening to a close action of an already opened notification with
id notificationId007:
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
let notificationContext = await frameworkProvider.getNotificationContext('notificationId007');
const requestObject = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnNotificationCloseActionEvent');
notificationContext.subscribe(requestObject, (response) => {
console.log(response.getResponseData().getNotificationId())
});
Here's a JavaScript example of listening to the close notification. The first part is to
open a notification with id, notificationId007. Once it's opened and the result is
success, we can add the code to listen to the close notification to listen to the close
notification. Below code contains code to listen close action of already opened
notification with id notificationId007:
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
let notificationContext = await frameworkProvider.getNotificationContext('notificationId007');
const requestObject = frameworkProvider.requestHelper.createPublishRequest('ShowNotification');
requestObject.setTitle('title');
notificationContext.publish(requestObject).then((message) => {
//given below is the code to listen to close notification of this notification
const requestObject = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnNotificationCloseActionEvent');
notificationContext.subscribe(requestObject, (response) => {
console.log(response.getResponseData().getNotificationId());
});
});