本文整理匯總了TypeScript中electron.Notification.isSupported方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Notification.isSupported方法的具體用法?TypeScript Notification.isSupported怎麽用?TypeScript Notification.isSupported使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類electron.Notification
的用法示例。
在下文中一共展示了Notification.isSupported方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: async
watcher.on(actions.notify, async (store, action) => {
const {
title = "itch",
body,
icon = DEFAULT_ICON,
onClick,
} = action.payload;
if (Notification.isSupported()) {
const n = new Notification({
title,
subtitle: null,
body,
icon: icon ? nativeImage.createFromPath(icon) : null,
actions: null,
});
if (onClick) {
n.on("click", e => {
store.dispatch(actions.focusWindow({ window: "root" }));
store.dispatch(onClick);
});
}
n.show();
} else {
logger.warn(`Cannot show notification: ${body}`);
}
});
示例2: showNotification
import { Notification } from 'electron';
import { logManager } from './log-manager';
import config from './config';
const isDesktopNotificationSupported = Notification.isSupported();
const logger = logManager.getLogger('TrackItemService');
export function showNotification(body, title = 'Tockler', onClick = null) {
if (isDesktopNotificationSupported) {
logger.info('Showing notification:', body, title);
const notification = new Notification({
title,
body,
silent: false,
icon: config.iconBig,
});
if (onClick) {
notification.once('click', onClick);
}
notification.show();
} else {
logger.error('Notifications not supported');
}
}