Remote Notifications and Mac

There’s no support for silent notifications on OS X in terms of content-available functionality
known from iOS (application is launched, can fetch content, …).

I can register for NSRemoteNotificationType.None:


I can implement application:didReceiveRemoteNotification::

func application(application: NSApplication,
    didReceiveRemoteNotification userInfo: [String : AnyObject]) {
    DDLogVerbose("Did receive remote notification (userInfo)")

And when I send empty aps dictionary with custom data like …

  "aps" : {
  "status" : {
    status = "DND"

… I’m going to find …

Did receive remote notification n
    ["aps": {}, "status": { "status" : "DND" }]

… in my log file. No entry in Notification
Center and custom data received. Application is not launched if not running, but
that’s not what I want in my application anyway. I’ve got kind of silent notification.

...didReceiveRemoteNotification: not called

Today I was pulling my hair out, because ...didReceiveRemoteNotification:
wasn’t called when I launched application from Xcode. I did click on notification
in Notification Center, different version was launched, etc.

I slowly realized that I already saw similar behavior when I was debugging
launch at login helpers. Wrong helper was launched, because of Spotlight and
Launch Services database.

Time to clean this mess.

  • System Preferences – Spotlight – Privacy – add Archives and DerivedData
    folders there. Both are in the ~/Library/Developer/Xcode folder. Spotlight
    will not index your Xcode builds, …
  • Remove application from the /Applications folder.
  • Reset the Launch Services database with lsregister -kill.
  • Register libraries and applications at default locations with lsregister -seed.

lsregister is located at:


That’s it – these steps did fix it for me. My application started to receive
remote notifications again even if launched from Xcode.

Spotlight addendum – similar behavior spotted when I was trying to update my application
via MAS.

  • Clicked on the Update button.
  • Progress bar, installed, great.
  • After some time – you have updates available. The app was listed there again. Hmm, clicked
    on the Update button 2nd time.
  • Progress bar, installed, great.
  • After some time – you have updates available. The app was listed there. WTF?

I clicked on the Update button 3rd time and then I realized that my Dropbox icon
was indicating synchronization. Hmm, didn’t change anything, clicked on it and …

I archive all versions of all applications in a Dropbox folder. Forgot to
tell the Spotlight to ignore this Dropbox folder. MAS realized that
the installed version (/Applications folder) is outdated and then did update
my Dropbox version when I clicked on the Update button. Again, again, again
and again.

Developing Mac applications? Don’t forget to
tell the Spotlight to ignore all your folders with archived versions of your apps.