In - (void)applicationWillResignActive:(UIApplication *)application
method,
- calculate the actual time to be shown, i.e. 48 hours + hours to 7pm of that day.
- cancel any current scheduled notification
- create a
UILocalNotification
and set the parameters needed (time to fire and alert text).
Edit based on comment:
If I understand you this should be what you want. It calculates a time that is 48 hours later, and manually set the fire time to 7pm. If the calculated time is greater than 7pm, it will be fired on the next day.
NSDate *currentDate = [NSDate date];
NSDate *futureTime = [currentDate dateByAddingTimeInterval:60*60*48];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSTimeZone *timeZone = [NSTimeZone systemTimeZone];
[calendar setTimeZone:timeZone];
NSDateComponents *components = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit fromDate:futureTime];
if ([components hour] >= 19) { // make it the next day
[components setDay:[components day] + 1 ];
}
[components setHour:19];
[components setMinute:00];
NSDate *alertTime = [calendar dateFromComponents:components];