启用uilocalnotification 需要每天启用此通知计划,我没有得到,我为每个工作小时创建了 3 种不同的方法,但事实并非如此。
上午 8:00
凌晨 12:00
下午 4:00
-(void)Hour_08 {
NSString *str = [NSString stringWithFormat: @"%@ 08:00", self.DayNow];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm"];
NSDate *date = [dateFormatter dateFromString: str];
UILocalNotification *OitoHorasNotification = [[UILocalNotification alloc]init];
[OitoHorasNotification setFireDate:date];
OitoHorasNotification.repeatInterval = NSDayCalendarUnit;
[OitoHorasNotification setAlertBody:@"is now 08:00"];
[[UIApplication sharedApplication]scheduleLocalNotification:OitoHorasNotification];
}
最佳答案
你看过this site了吗?因为它建议您使用 NSHourCalendarUnit
而不是 NSDayCalendarUnit
如果您在一整天后执行通知,就会出现这种情况。或者也许你整天都在执行通知,因此你的代码是正确的我会错过阅读你的问题
关于ios - UIlocalnotification 每天安排 - 8 :00 - 12:00 and 16:00,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21174228/