Electron Desktop Notifications not displaying on windows 10

╄→尐↘猪︶ㄣ 提交于 2019-12-10 19:08:51

问题


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

I am using electron-packager to build.

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.


回答1:


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

Electron multiplatform notifications

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.

This is the important part:

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

  ...
});



回答2:


The issue was I was setting the app id in multiple locations. I also needed to install with electron-builder and then it worked.



来源:https://stackoverflow.com/questions/52487062/electron-desktop-notifications-not-displaying-on-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!