- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在晚上 8:30:01 有一个每日预定通知。
当“设置”应用中的通知被关闭切换一周后,没有通知显示,这很完美。
问题是当通知在该周之后在“设置”应用中切换回ON时,前一周的所有通知都会显示 .
我想知道如何让通知不“累积”可以这么说。
这里是否缺少一行代码来“清除它们”?
ViewController.m
:
- (void)viewDidLoad {
[super viewDidLoad];
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
NSCalendar *cal = [NSCalendar currentCalendar];
NSDateComponents *comp = [cal components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute) fromDate:[NSDate date]];
comp.hour = 20; // 19 = 7PM 20=8pm
comp.minute = 30; // 7:45 PM 8:30
comp.second = 01; // 7:45:01 PM
localNotification.fireDate = [cal dateFromComponents:comp];
localNotification.alertBody = @"Local Notification in iOS8";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.repeatInterval = NSCalendarUnitDay;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
*这些是从通知关闭时开始显示的通知,只要我将通知切换回ON:*
最佳答案
当您将通知设置为关闭时,您应该调用 [[UIApplication sharedApplication] cancelAllLocalNotifications];
关于ios - 计划的本地通知在切换为 ON 的时间段内显示,切换为 OFF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29956882/
如果我使用以下方法计算 java.time 中 2 个 LocalDate 之间的差异: Period p = Period.between(testDate, today); 然后我得到一个包含年、
我正在开发一个有多种不同费率的预订平台。这些费率由一天中的时间、星期几和一年中的一天决定。以下是所涉及的间隔类型的一些示例: 周一至周五,上午 9 点至下午 5 点 周六和周日,中午 12 点到早上
我有大量数据,包括开始时间、停止时间和值。开始和停止时间因行而异,以 5 分钟为增量。我正在尝试创建一个新的数据框,该数据框具有 5 分钟的间隔以及该间隔在行的开始和停止范围内的所有行的总和。 我有一
我有一个这样的表: --------------------------------------------- |Id | Step | StartedAt
我有一个网络应用程序,用户将在其中输入 2 个日期。一个 StartDate 和一个 EndDate。现在我想编写它,以便在选择 StartDate 和 EndDate 时确定有多少周,然后显示这些周
这看起来并不直截了当。 我正在尝试: @Override public int compare(Period o1, Period o2) { return o1.toStandardDays
我必须为团队发送 session 邀请,这是我的邮件 $ical = 'BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 11.0
我有这个 ISO 8601 时间段字符串: P0Y0M0DT3H5M0.000S 并且 PHP7.4 无法用它构造 DateInterval。 format('%h Hours %m Minutes
我想要获取包含一段时间(格式为 HH:MM:SS)的多个单元格的总和。在 LibreOffice Calc 4.0.3.3 中,我复制粘贴了 G14:G21 范围内的时间段,并将单元格格式设置为时间
我有一个表(MySQL),每n秒捕获一次样本。该表有很多列,但重要的是两列:时间戳(TIMESTAMP 类型)和计数(INT 类型)。 我想做的是获取一定时间范围内计数列的总和和平均值。例如,我每 2
我有一个表(MySQL),每n秒捕获一次样本。该表有很多列,但重要的是两列:时间戳(TIMESTAMP 类型)和计数(INT 类型)。 我想做的是获取一定时间范围内计数列的总和和平均值。例如,我每 2
我在一个项目上使用 joda-time (1.6.2),我正在做的其中一件事就是计算预测时间和实际时间之间的差异。这种差异有时是积极的,有时是消极的。虽然适当的方法可能是使用 Duration 而不是
我有一个表 (MySQL),它每 n 秒捕获一次样本。该表有很多列,但最重要的是两列:一个时间戳(TIMESTAMP 类型)和一个计数(INT 类型)。 我想做的是获取计数列在一段时间内的总和和平均值
我想让我的折线图显示过去 3 个月的数据。 GDS 有一个“最后一个季度”的日期范围,但这显示的是 Q1、Q2、Q3 或 Q4。我需要的是过去3个整月(不算当月)的数据。我尝试创建一个计算字段,但事实
我想让我的折线图显示过去 3 个月的数据。 GDS 有一个“最后一个季度”的日期范围,但这显示的是 Q1、Q2、Q3 或 Q4。我需要的是过去3个整月(不算当月)的数据。我尝试创建一个计算字段,但事实
我是一名优秀的程序员,十分优秀!