我为OS开发了一个应用程序,应该发送本地通知。我为OSX10.9部署了这个应用程序。在苹果升级OSX10.10.3之前,该应用程序运行良好。我为一个标准用户(不是管理员)安装了这个应用程序,当我使用系统首选项-->通知时,我看不到应用程序有发送通知的权限。下面是我在OS上发送loca通知的代码:
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];在安装OS 10.10.3之后,苹果改变了什么?如果是的话,我的代码有什么问题?
发布于 2015-04-29 18:00:06
几样东西(我在这里的一个教程里找到的):
1)
不要使用scheduleNotification,而是尝试使用:
[center deliverNotification:notification];2)
Notification仅在应用程序不是最前端时才显示通知。要始终提供通知,您需要按照上面所示在NSUserNotificationCenter上设置委托,并按如下方式实现NSUserNotificationCenterDelegate:
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification
{
return YES;
}https://stackoverflow.com/questions/29946410
复制相似问题