I wanna repeat a local notification message every Wednesday 6.00 pm.
How would I do that?
For the moment I use following code. But even I try, nothing happens at this time. I logged the UIDate, it shows me 0001-01-01 17:25:52. I figured out, it is the wrong time zone. I am in the CEST time zone. How would I change that?
- (void)applicationDidEnterBackground:(UIApplication *)application {
//Calendar
NSCalendar *gregCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *dateCompnent = [gregCalendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitWeekday fromDate:[NSDate date]];
[dateCompnent setWeekday:4];
[dateCompnent setHour:18];
[dateCompnent setMinute:00];
UIDatePicker *dd = [[UIDatePicker alloc] init];
[dd setDate:[gregCalendar dateFromComponents:dateCompnent]];
//Notification
UILocalNotification *notification = [[UILocalNotification alloc] init];
[notification setAlertBody:@"Test Notification"];
[notification setFireDate:dd.date];
[notification setSoundName:@"sound.mp3"];
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
[application setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];
}