Page 2 of 2

Re: Notification

Posted: Sun Sep 11, 2016 8:22 pm
by wilbert
deseven wrote:I think i'm going to write a module so everyone can use native OS X notifications easily.
Sounds like a good idea :)

Re: Notification

Posted: Wed Sep 14, 2016 5:29 pm
by deseven
Done. Wrapped everything into one module, added support for custom event data.

github, direct link

Re: Notification

Posted: Wed Sep 14, 2016 9:01 pm
by wilbert
deseven wrote:Done. Wrapped everything into one module, added support for custom event data.

github, direct link
Nice work :)

Are you familiar with NSMutableDictionary ?
You could have used it instead of NSDictionary like this

Code: Select all

options = CocoaMessage(0, 0, "NSMutableDictionary dictionaryWithCapacity:", 0)
CocoaMessage(0, options, "setObject:", CocoaMessage(0,0,"NSNumber numberWithInteger:", *notification\alwaysShow), "forKey:$", @"alwaysShow")
CocoaMessage(0, options, "setObject:", CocoaMessage(0,0,"NSNumber numberWithInteger:", *notification\deleteAfterClick), "forKey:$", @"deleteAfterClick")
...

Re: Notification

Posted: Thu Sep 15, 2016 12:16 am
by deseven
Nope, i saw NSDictionary here and moved on from that. Didn't know that NSMutableDictionary is a subclass of NSDictionary.

Updated the code, thanks :)

Re: Notification

Posted: Thu Oct 14, 2021 9:07 pm
by deseven
By the way, NSUserNotification was deprecated and now you should use UNUserNotification instead. It's even more unfriendly and honestly it's much easier to just use terminal-notifier.

Naturally, my module above is also deprecated and won't receive any updates.