25

I'm using OSX's Notification Center APIs for the first time and can't seem to figure out how to make my app's icon to show up in the Notification badge.

The default "your app doesn't have an icon" icon keeps showing up:

Here's what I've done so far

  • I have created an icns file that includes 512, 256, 128, 32 & 16px versions
  • dragged the icon into the "App Icon" section of the target's summary
  • I made to sure to check the box to copy the icon into the project
  • the plist's "Icon file" section references the correct icon name (minus the .icns) part

Any ideas? The icon doesn't show up when I run the app thru Xcode or when I export an archive either.

I also have extracted the Sparrow.icns file from Sparrow.app and tried using that one instead of the one I made. That didn't work either.

Cœur
  • 37,241
  • 25
  • 195
  • 267
phatduckk
  • 1,775
  • 1
  • 14
  • 17
  • Possible Duplicate: http://stackoverflow.com/questions/11770961/how-to-make-builded-app-with-icon – Mil0R3 Aug 08 '12 at 02:28
  • I tried that - didn't work. http://cl.ly/image/3d1P271a0I3h http://cl.ly/image/1P0F2Z0o3a09 – phatduckk Aug 08 '12 at 02:43
  • That's puzzle, I used Icon Composer to make a icon.icns from icon.png,and then draged it to the target in Xcode,it would auto add to the plist, every thing was ok. – Mil0R3 Aug 08 '12 at 04:19

9 Answers9

22

I was able to fix this issue by incrementing the Build number in the General section for the build Target.

14

You can force the Notification Center to refresh all of the icons by deleting the Notification Center database file (~/Library/Application Support/NotificationCenter/SOME_UUID.db) and then killing the Notification Center process (e.g., from Activity Monitor).

Unfortunately this has the side effect of deleting your notification history, but this wasn't too much of an issue for me.

Kyle
  • 1,620
  • 14
  • 25
  • I tried this, but even after that the notification shows the apple's default icon. But when I login as another user icon comes correctly in the notification. Is there any way to clear all the cache or something like that? – Vipin Johney Apr 25 '13 at 06:47
  • 2
    This worked for me, the directory has changed however with 10.10 to `$(getconf DARWIN_USER_DIR)/com.apple.notificationcenter/db`. I deleted the file `db` and killed Notification Center via Activity Monitor. – Kilian Aug 25 '16 at 06:39
  • 1
    Here's a fun one-liner to delete the DB and kill NotificationCenter based on Kilian's helpful comment: `rm -rf $(getconf DARWIN_USER_DIR)/com.apple.notificationcenter/db && kill -9 \`ps -A | grep "[^(grep )]MacOS\/NotificationCenter" | awk '{print $1}'\`` – Logan Mar 28 '20 at 05:11
13

There's actually an ongoing debate on Apple's developer forums (link, link for people with access) about this. As far as I know, there's currently no real solution, but you can try the following:

  • Change your app's bundle ID and try it again. If you change it, clean your app, and change back, some people have reported success with seeing their icon show up.
  • Log in as another user. The caching Notification Center uses may be per-user, so you might be able to get the properly-iconned notifications as a different person.
Tim
  • 59,527
  • 19
  • 156
  • 165
  • 3
    Changing the bundle ID did the trick. Pretty lame bug. I wonder what happens to upgrades from the AppStore. – phatduckk Aug 08 '12 at 17:53
  • 2
    These devforums links solved my problem. For the record, I had moved an old version of my App in /Application. This is where Notification Center was "getting" the icon from, and this old version had a broken Icon (bad .iconset). Trashing this version and restarting the Notification Center fixed my problem! – StuFF mc Nov 28 '12 at 11:23
4

The folder location has been moved for OSX 10.10+.

Following command takes to you to its new location:

$ cd `getconf DARWIN_USER_DIR`/com.apple.notificationcenter/db               

and then

$ open .
Obj-Swift
  • 2,802
  • 3
  • 29
  • 50
1

Easiest way that I managed to get the icon to show up is change the Bundle Identifier in your project. This works on OSX 10.10.5 and XCode 7.2

(Once notification center picks up the change, you can change it back to your original bundle identifier if you already have a provisioning profile associated with it)

Quinton Wall
  • 178
  • 1
  • 2
1

I have solved the issue by archiving my app and adding a copy to my applications folder. When the app is in Application folder, the icon is always visible even you run the app from XCode...

emreoktem
  • 2,409
  • 20
  • 36
1

I tried all of the above suggestions but the only thing that worked for me on 10.14 was to delete DerivedData:

rm -rf ~/Library/Developer/Xcode/DerivedData

Aral Balkan
  • 5,981
  • 3
  • 21
  • 24
1

If anyone still having this issue, and none of the methods above worked, here is how I solved it:

  1. open Notifications from the System Preference (easiest is to open Alfred or spotlight and type Notifications)
  2. find your application and remove it (press backspace/delete button)

NOTE: this may remove all notifications

Kiura
  • 202
  • 3
  • 9
0

I am using Xcode 11.5 and I had the same problem. In my case tough, it was sufficient to clean build output, close and reopen the project. Then do a fresh build and let it run again. The icon was there afterwards.

Side note: I've placed the app icon for every size in the assets.xcassets file, except 1024 x 1024 pixels. Don't know if this is relevant or not. Hope that helps.

André Gasser
  • 1,065
  • 2
  • 14
  • 34