Skip to content

Instantly share code, notes, and snippets.

@skiyo
Created July 23, 2012 09:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skiyo/3162852 to your computer and use it in GitHub Desktop.
Save skiyo/3162852 to your computer and use it in GitHub Desktop.
NSUserNotificationCenter
//Initalize new notification
NSUserNotification *notification = [[NSUserNotification alloc] init];
//Set the title of the notification
[notification setTitle:@"My Title"];
//Set the text of the notification
[notification setInformativeText:@"My Text"];
//Set the time and date on which the nofication will be deliverd (for example 20 secons later than the current date and time)
[notification setDeliveryDate:[NSDate dateWithTimeInterval:20 sinceDate:[NSDate date]]];
//Set the sound, this can be either nil for no sound, NSUserNotificationDefaultSoundName for the default sound (tri-tone) and a string of a .caf file that is in the bundle (filname and extension)
[notification setSoundName:NSUserNotificationDefaultSoundName];
//Get the default notification center
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
//Scheldule our NSUserNotification
[center scheduleNotification:notification];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment