签到签退提醒
说明:还有5(10,15)分钟到上班时间时推送提醒消息,下班时间已过5(10,15)分钟时推送提醒消息,上班和下班时间均为从服务器获取的配置时间
NSDateFormatter *df=[[NSDateFormatter alloc] init];
[df setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
[df setDateFormat:@"HH:mm:ss"];
NSDate *date = [NSDate date];
NSTimeZone *zone = [NSTimeZone systemTimeZone];
NSInteger interval = [zone secondsFromGMTForDate: date];
NSDate *localeDate = [date dateByAddingTimeInterval: interval];
NSString *localStr = [df stringFromDate:localeDate];
NSDate *localDate = [df dateFromString:localStr];
//获取上班时间
NSString * amTime = [responseObject objectForKey:@"am"];
NSDate *amDate=[df dateFromString:amTime];
//获取下班时间
NSString * pmTime = [responseObject objectForKey:@"pm"];
NSDate *pmDate=[df dateFromString:pmTime];
if ([[UIApplication sharedApplication] currentUserNotificationSettings].types != UIUserNotificationTypeNone) {
if (inRemind == YES) {
if ([ isEqualToString:@"提前5分钟提醒"]) {
NSDate *advanceTime = [NSDate dateWithTimeInterval:-60 * 5 sinceDate:amDate];
NSTimeInterval inRemindTime=[advanceTime timeIntervalSinceDate:localDate];
UILocalNotification *notification=[[UILocalNotification alloc]init];
//设置调用时间
=[NSDate dateWithTimeIntervalSinceNow:inRemindTime];//通知触发的时间,10s以后
=kCFCalendarUnitDay;//循环通知的周期
//设置通知属性
=@"还有5分
签到签退提醒 来自淘豆网m.daumloan.com转载请标明出处.