最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Electron: Notification is not a constructor - Stack Overflow

programmeradmin6浏览0评论

I am trying to initialize an object of Notification provided by electron. But I am getting the error as: Uncaught Exception: TypeError: electron.Notification is not a constructor

I am doing this in Main process.

Code:

const electron = require('electron');
new electron.Notification({ title: "Cue", body: "Hello" }).show();

Electron version: 2.0.2/2.0.3

Any clues or ideas?

I am trying to initialize an object of Notification provided by electron. But I am getting the error as: Uncaught Exception: TypeError: electron.Notification is not a constructor

I am doing this in Main process.

Code:

const electron = require('electron');
new electron.Notification({ title: "Cue", body: "Hello" }).show();

Electron version: 2.0.2/2.0.3

Any clues or ideas?

Share Improve this question edited Jun 25, 2018 at 17:38 Akashdeep Saluja asked Jun 25, 2018 at 17:24 Akashdeep SalujaAkashdeep Saluja 3,0958 gold badges35 silver badges62 bronze badges 9
  • have you tried new Notification() rather than new electron.Notification()? – phuzi Commented Jun 25, 2018 at 17:28
  • @phuzi yup gives me not defined. – Akashdeep Saluja Commented Jun 25, 2018 at 17:29
  • which version of electron you're using? – OJ Kwon Commented Jun 25, 2018 at 17:30
  • @OJKwon 2.0.2/2.0.3 – Akashdeep Saluja Commented Jun 25, 2018 at 17:38
  • try debugging your code. What is electron.Notification? Is it undefined? – pushkin Commented Jun 25, 2018 at 17:52
 |  Show 4 more ments

1 Answer 1

Reset to default 8

I think you should write

new electron.remote.Notification({....})

instead of

new electron.Notification({....})
发布评论

评论列表(0)

  1. 暂无评论