In 10.9, NSUserNotification supports a new property "contentImage", which allows the use of a graphic within the notification itself. I was really hoping that there might be a way to usurp the notification screen ala iTunes' notifications, so it would appear as if the sender/bundle app icon is customized.
But it appears that the property only allows for a subset of what I'm looking for, and the contentImage property only handles images thusly:
Any ideas on a workaround?
NSUserNotification
makes no bones about being an extremely closed system. If you're in the market for private APIs, however, NSConcreteUserNotification
implements a method called set_identityImage:
. Pass that a valid NSImage, and the presented notification lays out its content exactly like that iTunes banner.
@interface NSUserNotification (CFIPrivate)
- (void)set_identityImage:(NSImage *)image;
@end
- (void)applicationDidFinishLaunching:(NSNotification *)notif {
NSUserNotification *notification = [[NSUserNotification alloc] init];
notification.title = @"Some Title";
notification.subtitle = @"Some subtitle";
[notification set_identityImage:[NSImage imageNamed:@"CF_Logo.png"]];
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With