Daily UILocalNotification firing more than once

落爺英雄遲暮 提交于 2019-12-25 02:42:50

问题


Hello i am facing a weird kind problem. Actually i want to schedule a daily notification (only once a day) at 8:00 AM. Below is my code for scheduling daily notification.

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"HH:mm"];
NSDate *date = [[NSDate alloc] init];
date = [formatter dateFromString:@"08:00"];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = date;
localNotification.timeZone=[NSTimeZone defaultTimeZone];
localNotification.alertBody = @"You just received a local notification";
localNotification.alertAction = @"View Details";
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.repeatInterval = NSDayCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[formatter release];
[date release];

My problem is, I receive 2 local notifications. One at 8:00 AM and other at 10:00 AM. Why i am getting notification at 10:00 AM. I am scheduling it at 8:00 AM only. I know UILocalNotification library have some other weird kind of problems/bugs on most of apple devices. I just want to confirm whether there is some mistake in my code or it is a weird behaviour of UILocalNotification Library. I dont know why Apple is not working on resolving the issues being reported by many developers about UILocalNotification.

Note: I am using Xcode 4.6 and iOS 6.1


回答1:


This would be the BEST link to get your answer.



来源:https://stackoverflow.com/questions/19762936/daily-uilocalnotification-firing-more-than-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!