Mac notification center support


#1

Does JUCE support mac "Notification Center [sic]"  messages? Does anyone have any example of code to do this? I had a quick look through the forum but I can't really see anything.

EDIT: 

I'm talking about NSUserNotification notifications.

I can find information on using QT for this, if anyone (with more Obj-C experience) has tried these. (http://stackoverflow.com/questions/22142592/mac-os-usernotificationcenter-in-qt)


#2

You will need a bit of Objective-C. This works for me:

Class theClass = NSClassFromString(@"NSUserNotificationCenter");
if (theClass)
{
    NSUserNotification *notification = [[NSUserNotification alloc] init];
    NSString *title = (NSString*) trackRef->getColumnString(ITrackRef::colTitle).toCFString();
    [notification setTitle:title];
    [title release];
    
    String msg;
    msg << trackRef->getColumnString(ITrackRef::colArtist) << NewLine::getDefault();
    msg << trackRef->getColumnString(ITrackRef::colFeed);
    
    NSString *cfMsg = (NSString*) msg.toCFString();
    [notification setInformativeText:cfMsg];
    [cfMsg release];
                    
    NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
    [center deliverNotification:notification];
    
    [notification release];
}