Created
July 23, 2012 09:49
-
-
Save skiyo/3162852 to your computer and use it in GitHub Desktop.
NSUserNotificationCenter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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