UIlocalnotification日程安排每天 - 8:00-12:00和16:00

时间:2014-01-16 22:27:16

标签: ios apple-push-notifications uilocalnotification

启用uilocalnotification 需要每天启用此通知计划,我没有得到,我为每个工作小时创建了3种不同的方法,但事实并非如此。

上午8:00

12:00 AM

下午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];

}

1 个答案:

答案 0 :(得分:3)

您是否看过this site,因为它建议您使用NSHourCalendarUnit代替NSDayCalendarUnit,如果您在整天后执行通知,就会出现这种情况。或者也许你整天都在进行通知,因此你的代码是正确的我会想念你的问题

相关问题