node.js - 来自 Electron 的 Node 服务的 Windows 通知

标签 node.js service electron node-windows node-notifier

我可以使用 node-notifier 从 electron 发送 windows 通知

notifier.notify({
    appName: "myapp",
    title: 'My notification',
    message: 'Hello, there!'
  });

我可以使用 node-windows 从 electron 运行服务

从我的主进程

var svc = new Service({
    name: 'MyService',
    description: '',
    script: 'MyService.js',
  });
svc.on('install', function () {
    console.log('Install complete.');
    svc.start();
  });
svc.install();

但是,当我尝试从由 Electron 创建的服务发送通知时,却没有出现。虽然我检查了服务中的代码在日志中没有任何错误地运行!

我知道这在 C# 中是可能的,但我如何在 Electron 中做到这一点?

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

谢谢

最佳答案

尝试使用内置 Electron 通知,文档在这里: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,只需将这行放在主进程中:app.setAppUserModelId('yourappid')

希望对你有帮助

关于node.js - 来自 Electron 的 Node 服务的 Windows 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52065533/

相关文章:

Android - 服务和 Activity 交互

Android 服务 onBind -> onStart

javascript - 允许 Electron 托管的 Web 应用程序调用 window.open 并像常规 Chrome 窗口一样使用结果

javascript - Electron - 如何将 base64 dataUrl 保存到文件

node.js - Heroku NodeJS 部署

javascript - Nodejs变量作用域问题

javascript - 在 Node.js 中的 res.render() 之后使用 server-sent-events

angular - 无法将来自服务方法的数据显示到组件中

fonts - 如何在 Electron 中设置最小字体大小?

javascript - ERR_CONNECTION_REFUSED http ://localhost:3000/socket. io/socket.io.js