node-notifier
node-notifier copied to clipboard
No notifications on macOS after build
I am getting notifications in my Electron app when it is in dev mode, but after it is built there are no notifications present.
I have my build setup with:
node: {
__filename: true,
__dirname: true
},
to account for webpacker and I also have my development and distribution profiles setup in Xcode which are detected during an Electron build. So I can (mostly) eliminate most of the common Electron and electron-builder issues that could cause node-notifier to be a problem.
Any thoughts here? I have no errors in the Console logging app.
What could be causing this?
Any thoughts?
the same here
the same problem on windows
Same problem here on macOS. When in dev mode it works fine, but when prod it doesnt' work.
It is working in dev mode even though I have:
node: {
__dirname: false,
__filename: false
},
I am using https://github.com/electron-react-boilerplate/electron-react-boilerplate boilerplate.
same here
My package.json (scroll it)
I run electron-builder -m to pack my app.
{
…
"main": "main.js",
"scripts": {
"postinstall": "electron-builder install-app-deps",
"start": "electron main.js",
"pack": "build --dir",
"dist": "build"
},
"build": {
"appId": "my.app.id",
"dmg": {
"contents": [
{
"x": 110,
"y": 270
},
{
"x": 370,
"y": 270,
"type": "link",
"path": "/Applications"
}
]
},
"mac": {
"category": "productivity",
"extendInfo": {
"CFBundleURLName": "myapp",
"CFBundleURLSchemes": [
"myapp"
]
}
},
},
"dependencies": {
"electron-is-dev": "^1.1.0",
"electron-updater": "^4.0.6",
"electron-window-state": "^5.0.3",
"node-notifier": "^5.4.0",
"url-parse": "^1.4.6"
},
"devDependencies": {
"asar": "^1.0.0",
"electron": "^4.1.4",
"electron-builder": "^20.39.0",
"electron-packager": "^13.1.1",
"electron-reloader": "^0.2.0"
}
}
@mikaelbr
I tried with this instruction : https://github.com/mikaelbr/node-notifier#within-electron-packaging.
That generates very heavy .dmg and .zip files, and node-notifier still don't work.
Moreover i don't have errors in my Developer Console. notifier is loaded.
Electron renderer.js
var notifier = require('node-notifier');
…
function Notify() {
console.log('Notify');
notifier.notify({
'title': 'BLABLA',
'subtitle' : 'BLABLA1',
'message': 'BLABLA2',
'closeLabel': 'Close',
'actions': ['Open'],
'sound': 'Pop',
'wait': true,
});
}
Developer Tools screenshot

After working one full day on node-notifier problems with Electron, i chose to use node-mac-notifier which works great under production.
node-notifier library seems powerful and has many stars, but many people seems to face build problems, even for windows. We could come back with node-notifier if stability with Electron comes true.
As an example Slack use node-mac-notifier and electron-windows-notifications which are stable versions, even for very old versions of Electron. You don't have as many options but that works.
You may need this: node-notifier-in-electron-vue
@ReAlign that's interesting, thanks for sharing. Even if wearen't using Vue though?
@Noitidart no, it‘s is just a simple handling of the situation <No notifications on macOS after build>,
I am just simple processing, ensure that can be used.
I fixed it with "asar": false in my build config
@Noitidart add asarUnpack option to electron-builder
"build": {
"asarUnpack": [
"./node_modules/node-notifier/vendor/**"
],
...
}
@leekangtaqi Thanks! You made my day!!