Windows 10上不显示Electron Desktop Notifications [英] Electron Desktop Notifications not displaying on windows 10

查看:1265
本文介绍了Windows 10上不显示Electron Desktop Notifications的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的电子应用程序未在Windows 10上显示桌面通知。Mac和Linux正常运行。

My electron app is not displaying desktop notifications on windows 10. Mac and Linux are working fine.

我正在使用电子包装程序进行构建。

I am using electron-packager to build.

文档显示在Windows 10上,必须将具有应用程序用户型号ID的应用程序快捷方式安装到开始菜单。所以我在main.js中调用app.setAppUserModelId(myID),并在C:\Users\sam\AppData\Roaming\Microsoft\Windows\Start Menu\Programs中放入.exe的快捷方式

Documentation says "On Windows 10, a shortcut to your app with an Application User Model ID must be installed to the Start Menu." so i call app.setAppUserModelId(myID) in main.js and i put a shortcut to the .exe inside C:\Users\sam\AppData\Roaming\Microsoft\Windows\Start Menu\Programs

仍然没有通知。我不确定哪一步做错了。

Still no notifications. I'm not sure which step I am doing wrong.

推荐答案

我正在使用电子生成器,它的工作原理就像一种魅力。

I'm using electron-builder and it works like a charm.

电子多平台通知

我上传了将此代码发送到我的 GitHub存储库。它可以在Windows,MacOS和Linux上运行。如果您希望通知在Windows上正常运行,则需要安装运行 npm run dist的应用。它会创建一个名为 dist的文件夹,您可以在其中找到安装程序。

I uploaded this code to my GitHub repository. It works on Windows, MacOS and Linux. If you want that notifications work on windows, you need to install the app running 'npm run dist'. It creates a folder called 'dist' where you can find the installer.

这是重要的部分:

app.on('ready', () => {
  if (process.platform === 'win32') {
    app.setAppUserModelId("com.ikobit.desktop-notifications");
  }

  ...
});

这篇关于Windows 10上不显示Electron Desktop Notifications的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆