lucgian841
lucgian841

Reputation: 2002

OS X 10.10.3 and notification center

I developed an app for OS X that should send local notification. I deployed this app for OS X 10.9. The app worked fine until Apple update OS X 10.10.3. I installed the app for a standard (not Administrator) user and when I go under System Preference --> Notification I can't see that the app has permission to send notification. Here's my code to send a loca notification on OS X:

NSUserNotification *notification = [[NSUserNotification alloc]init];
notification.title = title;
notification.informativeText = text;
notification.soundName = NSUserNotificationDefaultSoundName;

notification.userInfo = @{@"url": [NSString stringWithFormat:@"http://myurl.com/%@",detailParams]};                    
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
[center setDelegate:self];
[center scheduleNotification:notification];

Apple changed something after installation of OS X 10.10.3? If yes what's wrong with my code?

Upvotes: 2

Views: 396

Answers (1)

Michael Dautermann
Michael Dautermann

Reputation: 89509

A couple things (which I found at a tutorial here):

1)

Instead of scheduleNotification, try using:

[center deliverNotification:notification];

2)

Notification Center only displays notifications if the application is not frontmost. To always present the notification, you need to set the delegate on the NSUserNotificationCenter as shown above, and implement the NSUserNotificationCenterDelegate as follows:

- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification
{
    return YES;
}

Upvotes: 2

Related Questions