通知で指定されたアクションのリスニング
通知でトリガーされたアクションをリスニングするTypescriptの例を次に示します。 次のコードには、ID notificationId007ですでに開いている通知をリスニングするコードが含まれています:
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
let notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId007');
const requestObject:IEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnNotificationActionEvent') as IEventRequest;
notificationContext.subscribe(requestObject, (response) => {
const resp: INotificationActionEventResponse = response as INotificationActionEventResponse;
console.log(resp.getResponseData().getNotificationId())
console.log(resp.getResponseData().getActionId())
console.log(resp.getResponseData().getActionName())
});
Typescriptです。 最初の部分は、ID notificationId007の通知を開くことです。 開いて結果が成功したら、通知でトリガーされたアクションをリスニングするコードを追加できます。 この例では、2つのアクション、結合コールおよび拒否コールが追加されています。 これら2つのアクションは、通知にボタンとして表示されます。 このボタンのいずれかをクリックすると、アクションIDやアクション名などの詳細でトリガーされた特定のアクションをリスニングできます :
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
let notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId007');
const requestObject: IShowNotificationRequest = frameworkProvider.requestHelper.createPublishRequest('ShowNotification') as IShowNotificationRequest;
requestObject.setTitle('title');
requestObject.setActions([{id: 'join', name: 'Join Call'}, {id: 'reject', name: 'Reject Call'}]);
notificationContext.publish(requestObject).then((message) => {
const response: INotificationOperationResponse = message as INotificationOperationResponse;
//given below is the code to listen to actions triggered in the notification of this notification
const requestObject:IEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnNotificationActionEvent') as IEventRequest;
notificationContext.subscribe(requestObject, (response) => {
const resp: INotificationCloseActionEventResponse = response as INotificationCloseActionEventResponse;
console.log(resp.getResponseData().getNotificationId());
console.log(resp.getResponseData().getActionId());
console.log(resp.getResponseData().getActionName());
});
});
通知でトリガーされたアクションをリスニングするJavaScriptの例を次に示します。 次のコードには、ID notificationId007ですでに開いている通知をリスニングするコードが含まれています:
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
let notificationContext = await frameworkProvider.getNotificationContext('notificationId007');
const requestObject = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnNotificationActionEvent');
notificationContext.subscribe(requestObject, (response) => {
console.log(response.getResponseData().getNotificationId())
console.log(response.getResponseData().getActionId())
console.log(response.getResponseData().getActionName())
});
ID notificationId007の通知をオープンするためにリスニングするJavaScriptの例を次に示します。 開いて結果が成功したら、通知でトリガーされたアクションをリスニングするコードを追加できます。 この例では、2つのアクション、結合コールおよび拒否コールが追加されています。 これら2つのアクションは、通知にボタンとして表示されます。 このボタンのいずれかをクリックすると、アクションIDやアクション名などの詳細でトリガーされた特定のアクションをリスニングできます :
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
let notificationContext = await frameworkProvider.getNotificationContext('notificationId007');
const requestObject = frameworkProvider.requestHelper.createPublishRequest('ShowNotification');
requestObject.setTitle('title');
requestObject.setActions([{id: 'join', name: 'Join Call'}, {id: 'reject', name: 'Reject Call'}]);
notificationContext.publish(requestObject).then((message) => {
//given below is the code to listen to actions triggered in the notification of this notification
const requestObject = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnNotificationActionEvent');
notificationContext.subscribe(requestObject, (response) => {
console.log(response.getResponseData().getNotificationId());
console.log(response.getResponseData().getActionId());
console.log(response.getResponseData().getActionName());
});
});