hey guys,
I am trying to set a up time based notification but seem to have problem scheduling notifications that are in the same day (or close enough proximity) and older dates. Here's some of the code I'm working with:
This is where I create a reminder for a task with a date:
and I have a function that adds it to the list of local notifications:
However, if it doesn't notify me if I try to make the dates close (by like 10 secs) so I can test it. When I check the count of the scheduledlocalnotifications, it shows up as 0. I'm not sure what the problem is and I can't seem to find a solution. The only time it comes up as a problem is when the dates are close to each other or on the same day.
Logically, this doesn't make sense to me that this might be causing the notification to be not added as I can have tasks that I want myself to be reminded of within minutes or even hours. Any help would be appreciated. Thanks!
I am trying to set a up time based notification but seem to have problem scheduling notifications that are in the same day (or close enough proximity) and older dates. Here's some of the code I'm working with:
This is where I create a reminder for a task with a date:
Code:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
[dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
NSDate *reminderDate = [dateFormatter dateFromString:@"2012-07-05 23:47:25"];
and I have a function that adds it to the list of local notifications:
Code:
- (IBAction)addReminder:(id)sender
{
UILocalNotification *notification = [[UILocalNotification alloc] init];
if(notification)
{
notification.fireDate = self.task.reminderDate;
notification.timeZone = [NSTimeZone localTimeZone];
notification.repeatInterval = 0;
notification.alertBody = @"Test";
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
}
However, if it doesn't notify me if I try to make the dates close (by like 10 secs) so I can test it. When I check the count of the scheduledlocalnotifications, it shows up as 0. I'm not sure what the problem is and I can't seem to find a solution. The only time it comes up as a problem is when the dates are close to each other or on the same day.
Logically, this doesn't make sense to me that this might be causing the notification to be not added as I can have tasks that I want myself to be reminded of within minutes or even hours. Any help would be appreciated. Thanks!