我可以使用node-notifier
从电子发送窗口通知
notifier.notify({
appName: "myapp",
title: 'My notification',
message: 'Hello, there!'
});
我可以使用node-windows
从电子服务
从我的主要过程
var svc = new Service({
name: 'MyService',
description: '',
script: 'MyService.js',
});
svc.on('install', function () {
console.log('Install complete.');
svc.start();
});
svc.install();
但是当我尝试从电子创建的服务发送通知时没有显示出来。虽然我检查了服务中的代码是否在日志中运行没有任何错误!
我知道这在c#中是可能的,但我如何在电子中做到这一点?
任何指南如何从服务发送通知?
谢谢
尝试使用构建电子通知,文档在这里:https://electronjs.org/docs/tutorial/notifications。如果您尝试但它不起作用,您必须错过这个:
在Windows 10上,必须在“开始”菜单中安装具有应用程序用户模型ID的应用程序快捷方式。
您必须在主进程中设置AppID,只需将此行放在main:app.setAppUserModelId('yourappid')
中
希望这可以帮助