Notification

Mac OSX specific forum
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Notification

Post 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 :)
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
deseven
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Notification

Post by deseven »

Done. Wrapped everything into one module, added support for custom event data.

github, direct link
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Notification

Post 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")
...
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
deseven
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Notification

Post 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 :)
User avatar
deseven
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Notification

Post 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.
Post Reply