我这样做是为了在设定的时间获得警报。但它没有及时报警。我正在从 datepicker 设置时间。我怎样才能解决这个问题?
- (void)scheduleNotificationWithInterval:(int)minutesBefore {
[[UIApplication sharedApplication] cancelAllLocalNotifications];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
NSLog(@"Date %@",datePicker.date);
localNotif.fireDate = datePicker.date;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
if ([freq isEqualToString:@"Daily"]) {
localNotif.repeatInterval = NSDayCalendarUnit;
}
localNotif.alertBody = @"Radio Asia Alarm";
localNotif.alertAction = @"Ok";
localNotif.soundName = UILocalNotificationDefaultSoundName;
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"Radio Asia Alarm" forKey:@"Message"];
localNotif.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
}
我也调用此方法,在设置时间和日期后单击按钮
[self scheduleNotificationWithInterval:1];
我没有警觉。我可以做什么?