Skip to content

Instantly share code, notes, and snippets.

@beccadax
Created February 26, 2013 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beccadax/5036219 to your computer and use it in GitHub Desktop.
Save beccadax/5036219 to your computer and use it in GitHub Desktop.
When a user notification fires while your Mac app is already in the foreground, this code plays the sound, but suppresses the rest of the notification. Put it in your user notification center delegate.
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)note {
if(note.soundName) {
[[NSSound soundNamed:note.soundName] play];
}
return NO;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment