2014-12-12 2 views
0

Я Запланированный мое местное уведомление огня в 4.00 часов и хочу, чтобы уведомление ежедневно в 4.00 часов, но пожары уведомления до времени в 3.44 вечера, 3:47 вечер и т.д.UILocalNotification Schehduling вопрос

вот код -

NSCalendar *calendar = [NSCalendar currentCalendar]; 
NSDateComponents *dateComponents = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:self.datePicker.date]; 
NSDateComponents *timeComponents = [calendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:self.datePicker.date]; 
[dateComponents setHour:[timeComponents hour]]; 
[dateComponents setMinute:[timeComponents minute]]; 
[dateComponents setSecond:0.0]; 

UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 
localNotification.alertBody = [NSString stringWithFormat:@"How are you feeling?"]; 
localNotification.soundName = UILocalNotificationDefaultSoundName; 
localNotification.fireDate = [calendar dateFromComponents:dateComponents]; 
localNotification.repeatInterval = kCFCalendarUnitDay; 

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 
+0

Попробуйте установить секунду на 1,0 – cyberlobe

ответ

0

Попробуйте это:

NSDate *myDate = [NSDate date]; // Set your time here 
myDate = [myDate dateByAddingTimeInterval:1*24*60*60]; 
UILocalNotification *notif = [[UILocalNotification alloc] init]; 
notif.fireDate = myDate; 
notif.timeZone = [NSTimeZone defaultTimeZone]; 
notif.alertBody = [NSString stringWithFormat:@"How are you feeling?"]; 
notif.alertBody = @"Reminder is set"; 
notif.soundName = UILocalNotificationDefaultSoundName; 
notif.repeatInterval = NSDayCalendarUnit; 
[[UIApplication sharedApplication] scheduleLocalNotification:notif]; 

Надеется, что это поможет.