I am working with UILocalNotification. My app will give user facility to set the reminder for any meeting and medicine in my application.
我正在使用UILocalNotification。我的应用程序将为用户提供设置,以便在我的应用程序中为任何会议和药物设置提醒。
I am Able to schedule UINotification according to my Schedule date. And also When user will schedule past date notification my secound schedule notification is not fired. After secound others are firing perfect but secound is not firing.
我可以根据我的日程安排日程安排UINotification。并且当用户将安排过去的日期通知时,我的secound日程安排通知不会被触发。在其他人发射完美之后,但是没有射击。
Following is my flow for notification:
以下是我的通知流程:
-
I am creating 3 schedule for meeting one of its time is past of my current time say for e.g. 2014-01-28 18:00. And my current device time is 2014-01-28 19:00. Now i am creating another schedule its time is i.e. 2014-01-28 19:10. And another schedule date and time is i.e. 2014-01-28 19:20.
我创建了3个会议时间表,其中一个时间已经超过了我目前的时间。 2014-01-28 18:00我目前的设备时间是2014-01-28 19:00。现在我正在制定另一个时间表,时间是2014-01-28 19:10。另一个计划日期和时间是2014-01-28 19:20。
-
With the above schedule date time reference my first notification which was of past date was fired after schedule create.
使用上述计划日期时间参考我的第一个通知是过去的日期是在计划创建后触发的。
-
When my current time of device come to 2014-01-28 19:10. I was especting notification. but it wount fire.
当我的设备当前时间到了2014-01-28 19:10。我在考虑通知。但它起火了。
-
And at 2014-01-28 19:20 my 3rd notification fires as regularly. this things happen for me every times when I add past date as a schedule.
在2014-01-28 19:20,我的第3次通知会定期发生。当我将过去的日期添加为时间表时,每次都会发生这种情况。
Following is my schedule notification code which i used to schedule notification:
以下是我用于安排通知的日程安排通知代码:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = fireDate;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = alertText;
localNotification.alertAction = alertAction;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.alertLaunchImage = launchImage;
localNotification.applicationIconBadgeNumber = 1;
localNotification.userInfo = userInfo;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[[UIApplication sharedApplication]registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
Also Following is my idReceiveLocalNotification: method to hendle notification:
以下是我的idReceiveLocalNotification:hendle通知的方法:
if([UIApplication sharedApplication].applicationIconBadgeNumber == 0) {
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];
}else{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}
Also when i get notification at that time i will call MkLocalNotificationScheduler class to display alert which code is as follows:
此外,当我收到通知时,我将调用MkLocalNotificationScheduler类来显示警报,其代码如下:
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Reminder"
message:[thisNotification alertBody]
delegate:self
cancelButtonTitle:@"NO"
otherButtonTitles:@"YES",nil] autorelease];
alert.tag = 1;
[alert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];
Please help me how to work on to get all Schedule notification weather it is past date or date yet to be come.
请帮助我如何工作,以获得所有时间表通知天气它已过去的日期或日期。
1 个解决方案
#1
2
Do not create UILocalNotification for time that is past. The behavior that you are seeing is typical of UILocalNotification. It fires past event right away. So in your code check if the time has past and if it is then don't create a UILocalNotification. (also its non-sense to create a notification of past time)
不要为过去的时间创建UILocalNotification。您看到的行为是典型的UILocalNotification。它会立即触发过去的事件。因此,在您的代码中检查时间是否已经过去,如果是,则不要创建UILocalNotification。 (也是无意义地创建过去时间的通知)
Only create new UILocalNotification for times that are in future of your current time.
仅在当前时间的未来时间内创建新的UILocalNotification。
#1
2
Do not create UILocalNotification for time that is past. The behavior that you are seeing is typical of UILocalNotification. It fires past event right away. So in your code check if the time has past and if it is then don't create a UILocalNotification. (also its non-sense to create a notification of past time)
不要为过去的时间创建UILocalNotification。您看到的行为是典型的UILocalNotification。它会立即触发过去的事件。因此,在您的代码中检查时间是否已经过去,如果是,则不要创建UILocalNotification。 (也是无意义地创建过去时间的通知)
Only create new UILocalNotification for times that are in future of your current time.
仅在当前时间的未来时间内创建新的UILocalNotification。