node.js – 来自电子节点服务的Windows通知

我可以使用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.

如果您尝试但它不起作用,您必须错过这个:

On Windows 10, a shortcut to your app with an Application User Model ID must be installed to the Start Menu.

您必须在主进程中设置AppID,只需将此行放在main中:app.setAppUserModelId(‘yourappid’)

希望这可以帮助

点赞