【发布时间】:2015-01-21 21:21:20
【问题描述】:
我的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 优胜美地
如何让这个通知总是显示,就像它总是播放声音一样?
【问题讨论】:
标签: objective-c macos nsusernotification