#Notification from main, MacOS

10 messages · Page 1 of 1 (latest)

hallow mortar
#

I am showing a notification from the main process on MacOS:

    notify(duration: number) {
        const notification = new Notification({
            title: '3DPrinter needs paused',
            body: 'for user attention',
        })
        notification.on('close', () => {
            if (this.statusManager.printerNeedsAttention()) {
                this.notify(duration)
            }
        })

        notification.on('action', () => {
            console.debug('action')
        })
        notification.on('show', () => {
            console.debug('show')
        })
        notification.on('reply', () => {
            console.debug('reply')
        })
        notification.on('click', () => {
            console.debug('click')
        })
        notification.show()
    }
```. I see the notification.  When I click on it, it goes away, but none of the event emitter's seem to fire.  Suggestions for how I'm doing it wrong welcome.
trim hearth
#

notify is a function?
maybe you should declare the notification and the listener outside the function and leave it inside the notify only for displaying

#

like

//mains.js
(...)
const notification = new Notification(...youOptions)
notification.on('click' () => { console.debug('click')});

function notify(duration:number){
notification.show();
}
(...)
hallow mortar
#

It's a method, but I can something similar.

#

Not sure if that helped or not. Now I'm seeing it timeout after about 5 seconds, unless I move my mouse pointer over it within 5 seconds. Definitely not what I want. How can it be made "durable".

hallow mortar
#

Tried it. Does nothing. This is macos, and the docs indicate it is only linux and windows.

trim hearth
#

oh sorry, I didn't realize

#

I don't know how it is in mac