Frage

Is there (now) a officially supported way to change the OSX Notification Center's Icon for NSUserNotifications while my App is running? I searched the web, but the answers weren't really "recent", so I just wanted to double check.

I'd like to show the currently playing spotify track's Artwork next to it's title / name

What I tried until now is really ugly:

  1. temporarily replacing the CFBundleIconFile of my app with a IconFamily generated .icns file (I know i shouldn't modify anthing inside the bundle, but I'm not aiming to get the app to the App Store)

  2. restart Notification Center to "forget" it's eventually cached icons

    NSRunningApplication* notificationCenter = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.notificationcenterui"]; [notificationCenter terminate];

    (i know I REALLY SHOULDN'T do this)

War es hilfreich?

Lösung

If you are NOT going to submit your app to App Store, there's a private API in 10.9 that does what iTunes did:

NSUserNotification *notification = [NSUserNotification new];
[notification setValue:anImage forKey:@"_identityImage"];

enter image description here

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top