AutoTimeoutで通知を表示
次に、autoTimeoutを使用した通知の例を示します。 通知は指定された秒後に自動的にクローズします。
Typescriptの例を次に示します:
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.setAutoTimeout(10);
notificationContext.publish(requestObject).then((message) => {
const resp = message as INotificationOperationResponse;
});
JavaScriptの例を次に示します:
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');
requestObject.setAutoTimeout(10);
notificationContext.publish(requestObject).then((resp) => {
//custom Code
}).catch((err) => {
console.log(err);
});