0
Я создал систему уведомлений, которая ежедневно выталкивает уведомление по адресу 12:02, но я не знаю, что мой код работает и выталкивает уведомления из приложения только на один или два дня! не могли бы вы помочь мне найти проблему?Проблема с ежедневным UILocaleNotification
- (void) LocalNotificationManager {
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSPersianCalendar];
NSDate *now = [NSDate date];
NSDateComponents *componentsForFireDate = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit| NSSecondCalendarUnit) fromDate: now];
[componentsForFireDate year];
[componentsForFireDate month];
[componentsForFireDate day];
[componentsForFireDate setHour:00];
[componentsForFireDate setMinute:2];
[componentsForFireDate second];
NSDate *fireDateOfNotification = [calendar dateFromComponents: componentsForFireDate];
notification = [[UILocalNotification alloc]init];
notification.fireDate = fireDateOfNotification;
notification.timeZone = [NSTimeZone localTimeZone];
notification.repeatInterval= NSYearCalendarUnit;
NSString *date = [self showPersianFullDate];
notification.alertBody = [NSString stringWithFormat:@"today is : %@ \n event : %@ \n" ,date , events.text];
[self createEvents];
[self retriveData];
notification.alertAction = @"View";
notification.soundName = @"webcam_on.aif";
NSUserDefaults *notificationDefaults = [NSUserDefaults standardUserDefaults];
BOOL DAILYNOTIF = [notificationDefaults boolForKey:@"dn"];
if (DAILYNOTIF == YES) {
NSLog(@"DN is Active");
[[UIApplication sharedApplication] scheduleLocalNotification:notification];}
}