通知のクローズ・イベントをリスニング
クローズ通知をリスニングするTypescriptの例を次に示します。 次のコードには、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())
});
Typescriptの例を次に示します。 最初の部分は、ID notificationId007の通知を開くことです。 開いて結果が成功したら、クローズ通知をリスニングするコードを追加できます:
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())
});
});
クローズ通知をリスニングするJavaScriptの例を次に示します。 次のコードは、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())
});
クローズ通知をリスニングするJavaScriptの例を次に示します。 最初の部分は、ID notificationId007の通知を開くことです。 開いて結果が成功したら、クローズ通知をリスニングするコードを追加してクローズ通知をリスニングできます。 次のコードには、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());
});
});