當我設置過去日期通知時,UILocal通知不會按計划日期和時間觸發

[英]UILocal Notification not fire on schedule date and time when i set past date notification


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:

以下是我的通知流程:

  1. 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。

  2. With the above schedule date time reference my first notification which was of past date was fired after schedule create.

    使用上述計划日期時間參考我的第一個通知是過去的日期是在計划創建后觸發的。

  3. 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。我在考慮通知。但它起火了。

  4. 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。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2014/01/28/72a07a1d9818a395d40f8aa7e77a05c6.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com