【发布时间】:2014-07-28 19:33:24
【问题描述】:
我已经在 App Delegate 中设置了本地通知使用这个:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
UILocalNotification *notification = [[UILocalNotification alloc]init];
[notification setAlertBody:@"Watch the Latest Episode of CCA-TV"];
[notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:5]];
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
[application setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];
}
当我运行应用程序然后退出时,我收到一条错误消息:
2014-06-07 11:14:16.663 CCA-TV[735:149070] 正在尝试安排本地通知 {fire 日期 = 2014 年 6 月 7 日星期六 11:14:21 太平洋夏令时间,时间 zone = America/Los_Angeles (PDT) offset -25200 (Daylight),重复 间隔 = 0,重复计数 = UILocalNotificationInfiniteRepeatCount, 下一次火灾日期 = 2014 年 6 月 7 日星期六 11:14:21 Pacific Daylight Time, user info = (null)} 有警报但未收到 用户允许显示警报
如何获得显示警报所需的权限?
【问题讨论】:
-
我认为应用程序已经拒绝了一次权限,您可以尝试从设置中启用。但顺便说一下 UILocalNotification 不需要用户权限..
-
试试
registerUserNotificationSettings。如果是 iOS 8,这个线程会回答你的问题。但是,请先看看 -stackoverflow.com/questions/24006998/…
标签: ios cocoa-touch notifications ios8 uilocalnotification