[英]Mavericks NSUserNotification not sending when app not main
当应用程序是主应用程序时,通知正常传递,但是当失去焦点时,则不会传递通知。 我试过记录(BOOL)userNotificationCenter:shouldPresentNotification:
在后台我什么也没收到,但是在main时却按预期记录。
码:
NSUserNotification * note = [[NSUserNotification alloc] init];
NSUserNotificationCenter * unc = [NSUserNotificationCenter defaultUserNotificationCenter];
unc.delegate = self;
note.title = track.title;
note.subtitle = track.artist;
[unc deliverNotification:note];
委托方法
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {
return YES;
}
编辑
我在[unc deliverNotification:note];
之前添加了一个断点[unc deliverNotification:note];
在我恢复后,通知始终有效。 Whaaa?
尝试摆脱unc.delegate = self;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.