INotificationContext
INotificationContextを使用すると、Notificationsでアクションとイベントを実行できます。たとえば、「通知の表示」、「通知のクローズ」、「通知のクローズのリスニング」、「通知のアクションのリスニング」などです。
NotificationContextへの参照を取得するには、getNotificationContext function.dsを使用
構文は次のとおりです:
getNotificationContext(notificationId: string): Promise<INotificationContext>;
Typescriptのコード・サンプルを次に示します。
/// <reference path="uiEventsFramework.d.ts"/>
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
const notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId');
Javascriptのコード・サンプルを次に示します。
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
const notificationContext = await frameworkProvider.getNotificationContext('notificationId');
関数
サブスクライブ
このファンクションを使用して、SidePaneContextでサポートされているイベントをリスニングします。
次に、構文の例を示します:
subscribe: (requestObject: IEventRequest, callbackFunction: (response:IEventResponse) => void) => ISubscriptionContext;
Typescriptのコード・サンプルを次に示します。
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())
});
Javascriptのコード・サンプルを次に示します。
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())
});
subscribeOnce
この関数を使用して、クローズ・イベントを1回リスニングします。
次のコード例は、構文を示しています:
subscribeOnce: (requestObject: IEventRequest, callbackFunction: (response:IEventResponse) => void) => ISubscriptionContext;
Typescriptのコード・サンプルを次に示します:
//// <reference path="uiEventsFramework.d.ts"/> 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.subscribeOnce(requestObject, (response) => {
const resp: INotificationCloseActionEventResponse = response as INotificationCloseActionEventResponse;
console.log(resp.getResponseData().getNotificationId())
});
JavaScriptのコード・サンプルを次に示します:
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.subscribeOnce(requestObject, (response) => {
console.log(response.getResponseData().getNotificationId())
});
公開
このファンクションを使用して、NotificationContextオブジェクトに対してサポートされている操作を公開します。
次のコード例は、構文を示しています:
publish: (requestObject: IOperationRequest) => Promise<IOperationResponse>;
Typescriptのコード・サンプルを次に示します:
/// <reference path="uiEventsFramework.d.ts"/> const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
let notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId007');
const payload: IShowNotificationRequest = frameworkProvider.requestHelper.createPublishRequest('ShowNotification') as IShowNotificationRequest)
payload.setTitle(fieldName);
payload.setSummary('Error message summary');
notificationContext.publish(requestObject).then((message) => {
const response: INotificationOperationResponse = message as INotificationOperationResponse;
//custom code
});
JavaScriptのコード・サンプルを次に示します:
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
let notificationContext = await frameworkProvider.getNotificationContext('notificationId007');
const payload = frameworkProvider.requestHelper.createPublishRequest('ShowNotification');
payload.setTitle(fieldName);
payload.setSummary('error message summary ');
notificationContext.publish(payload).then((response) => {
// custom code
}).catch((err) => {
console.log(err);
});
処分
NotificationContextオブジェクトでサブスクライブされているすべてのイベントを削除するには、このファンクションを使用します。
dispose:() => void;
次のコード・サンプルは、Typescriptの例を示しています:
/// <reference path="uiEventsFramework.d.ts"/>
const disposeSidePaneEvents = async () => {
const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');
const notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId007');
notificationContext.dispose();
}
次のコード・サンプルは、JavaScriptの例を示しています:
const disposeSidePaneEvents = async () => {
const uiEventsFrameworkInstance = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');
const notificationContext = await frameworkProvider.getNotificationContext('notificationId007');
notificationContext.dispose();
}
getSupportedEvents
このファンクションを使用して、NotificationContextオブジェクトでサポートされているすべてのイベントを取得します。
次のコード例は、構文を示しています:
getSupportedEvents(): string[];
次のコード・サンプルは、Typescriptの例を示しています。
/// <reference path="uiEventsFramework.d.ts"/>
const getSupportedEvents = async () => {
const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');
const sidePaneContext: ISidePaneContext = await uiEventsFrameworkInstance.getSidePaneContext('sidePaneId');
const supportedEvents: string[] = sidePaneContext.getSupportedEvents();
}
次のコード・サンプルは、Javascriptの例を示しています。
const getSupportedEvents = async () => {
const uiEventsFrameworkInstance = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');
const sidePaneContext = await uiEventsFrameworkInstance.getSidePaneContext('sidePaneId');
const
getSupportedActions
このファンクションを使用して、NotificationContextオブジェクトでサポートされるすべてのアクションを取得します。
次のコード例は、構文を示しています:
getSupportedActions(): string[];
次のコード・サンプルは、Typescriptの例を示しています。
/// <reference path="uiEventsFramework.d.ts"/>
const getSupportedActions = async () => {
const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');
const notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId007');
const supportedActions: string[] = notificationContext.getSupportedActions();
}
次のコード・サンプルは、JavascriptのgetSupportedActionsの例を示しています。
const getSupportedActions = async () => {
const uiEventsFrameworkInstance = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');
const notificationContext = await uiEventsFrameworkInstance.getNotificationContext('notificationId007');
const