So I have an app that includes repeat intervals local notification and I would like to add a feature that will pause the notifications during sleep time.
So far, I have created two datepickers for the user to spicify what time they would like to stop the repeat interval and what time to restart again automatically. And I have added a uiswitch for them to activate the sleep mode or ignore the feature.
Now, how would I make my main uipickerview -( which they choose there notification from here) - to listen to the uiswitch if it is on, then it pause the notifications at the time that comes from my first datepicker and reintitiate the notifications at the time that comes from the second datepicker?
I have already setup my datepickers and my uiswitch but have no idea how to implement it with my uipickerview.. Should it be under the method of DidSelectRow? Or a method in appdelegate ( like DidEnterBackground)?
Please ask if you need more info or codes to understand the idea and help me. Thanks.
ADD ON:
Here is my code that I have prepared for the datepicker, however, I'm just missing the connection to add it to my picker view properly.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
dateFormatter.timeZone=[NSTimeZone defaultTimeZone];
dateFormatter.timeStyle=NSDateFormatterShortStyle;
dateFormatter.dateStyle=NSDateFormatterShortStyle;
NSString *dateTimeString=[dateFormatter stringFromDate:startTime.date];
NSLog(@"Start time is %@",dateTimeString);
NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc]init];
dateFormatter2.timeZone=[NSTimeZone defaultTimeZone];
dateFormatter2.timeStyle=NSDateFormatterShortStyle;
dateFormatter2.dateStyle=NSDateFormatterShortStyle;
NSString *dateTimeString2=[dateFormatter2 stringFromDate:endTime.date];
NSLog(@"End time is %@",dateTimeString2);
I also have this code to compare between the times:
if ([[NSDate date] isEqualToDate:startTime.date]) {
NSLog(@"currentDate is equal to startTime");
}
if ([[NSDate date] isEqualToDate:endTime.date]) {
NSLog(@"currentDate is equal to endTime");
}