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];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.