Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hello world code for Mountain Lion OSX 10.8 showing notification like iChat

Is there any example for showing a hello world notification on Mountain Lion OSX 10.8 (the new notification center).

Just to add visual clarity here is what I am talking about: Notification Center Notification

like image 488
MaX Avatar asked Jul 18 '12 18:07

MaX


2 Answers

I finally found answer after a little help from @Alexsander.

NSUserNotification *notification = [[NSUserNotification alloc] init];
[notification setTitle:@"Hello World"];
[notification setInformativeText:@"Hello world message"];
[notification setDeliveryDate:[NSDate dateWithTimeInterval:20 sinceDate:[NSDate date]]];
[notification setSoundName:NSUserNotificationDefaultSoundName];
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
[center scheduleNotification:notification];

Hope it helps people

like image 101
MaX Avatar answered Nov 17 '22 23:11

MaX


Look up NSUserNotification and NSUserNotificationCenter.

like image 20
Alexsander Akers Avatar answered Nov 17 '22 23:11

Alexsander Akers