node-notifier icon indicating copy to clipboard operation
node-notifier copied to clipboard

No notifications on macOS after build

Open kevinelliott opened this issue 5 years ago • 14 comments

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?

kevinelliott avatar Mar 06 '19 04:03 kevinelliott

Any thoughts?

kevinelliott avatar Mar 14 '19 20:03 kevinelliott

the same here

Ivorfason avatar Mar 21 '19 13:03 Ivorfason

the same problem on windows

Ghefest avatar Mar 25 '19 01:03 Ghefest

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.

Noitidart avatar Apr 07 '19 18:04 Noitidart

same here

Aarbel avatar Apr 14 '19 13:04 Aarbel

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"
  }
}

Aarbel avatar Apr 14 '19 14:04 Aarbel

@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 image

Aarbel avatar Apr 14 '19 14:04 Aarbel

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.

Aarbel avatar Apr 14 '19 18:04 Aarbel

You may need this: node-notifier-in-electron-vue

ReAlign avatar May 05 '19 02:05 ReAlign

@ReAlign that's interesting, thanks for sharing. Even if wearen't using Vue though?

Noitidart avatar May 05 '19 02:05 Noitidart

@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.

ReAlign avatar May 05 '19 02:05 ReAlign

I fixed it with "asar": false in my build config

pablopunk avatar Jun 01 '19 02:06 pablopunk

@Noitidart add asarUnpack option to electron-builder

"build": {
    "asarUnpack": [
      "./node_modules/node-notifier/vendor/**"
    ],
    ...
}

leekangtaqi avatar Feb 11 '20 12:02 leekangtaqi

@leekangtaqi Thanks! You made my day!!

lee-gyu avatar Dec 18 '20 07:12 lee-gyu