我NSUserNotification
正在交付,播放给定的声音,但如果我的应用程序不是最顶层的应用程序,则不会在屏幕上直观地显示。
如果我的应用程序在后台,则不会显示通知。如果我的应用程序处于活动状态,它会显示。在这两种情况下,声音都会播放。
这是我发送通知的方式:
NSUserNotification *notification = [[NSUserNotification alloc] init];
[notification setTitle: @"hi"];
[notification setSoundName: NSUserNotificationDefaultSoundName];
[notification setDeliveryDate: [NSDate dateWithTimeIntervalSinceNow: 3]];
[[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification: notification];
我最重要shouldPresentNotification
的是始终呈现它。
[NSUserNotificationCenter defaultUserNotificationCenter].delegate = self;
...
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {
return YES;
}
OSX 10.10.1 优胜美地
如何使此通知始终显示,就像它始终播放声音一样?