来自电子节点服务的Windows通知

问题描述 投票:4回答:1

我可以使用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#中是可能的,但我如何在电子中做到这一点?

任何指南如何从服务发送通知?

谢谢

node.js service electron node-windows node-notifier
1个回答
1
投票

尝试使用构建电子通知,文档在这里:https://electronjs.org/docs/tutorial/notifications。如果您尝试但它不起作用,您必须错过这个:

在Windows 10上,必须在“开始”菜单中安装具有应用程序用户模型ID的应用程序快捷方式。

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

希望这可以帮助

© www.soinside.com 2019 - 2024. All rights reserved.