0
我已經創建了一個通知系統,每天推送通知12:02 AM但我不知道我的代碼作品,並從應用程序推送通知一兩天!你能幫我找到問題嗎?問題與日常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];}
}