Does iOS invalidates localNotifications if the user modifies the date/time - iphone

If current date is 20-November-2012 9:00 AM, in my app if I schedule a local notification with firedate say 21-November-2012 10:00 AM and run my application and if I modify the date/time in settings to some previous date say 18-November-2012 I will get the notification properly when the date/time reaches the firedate.
But if I change the date/time to any upcoming date say 30-November-2012 10::PM in device settings I am not getting the notification. Does iOS invalidates localNotifications if the user sets the the date/time to any upcoming date.

When you fire a LocalNotification that notification will get registered into the OS.OS present the notification on time.You can see the notifications your App has registered using the code
`[[UIApplication sharedApplication] scheduledLocalNotifications]`
You CANT edit any notification that is already registered in the OS.
If you want to edit any notification , cancel the previous notification and fire a new one using the updated firedate.
I never understood how you get a notification in 18-November-2012 if the current date is 20-November-2012 9:00 AM.

Related

UILocalNotification multiple firing

I schedule a UILocalNotification at at specific date, and the notification is fired correctly, But the problem is that I receive multiple alerts at random dates for same notification even though the notification is not repeated (repeatInterval = 0 ).
Another note, when I receive the notification at first time , it appears correctly in notification center, but later when I receive the multiple alerts nothing updated in notification center.
Please note that this event is repeated daily, but the notification not get repeated.
Any solution for this issue?
I expect you are never calling:
[[UIApplication sharedApplication] cancelAllLocalNotifications]
These notifications appear to be "old" notifications that haven't been cancelled and are still due to fire. Did you ever have a repeat interval? Some of these notifications could be repeated from very old notifications

How to schedule a local notification if an action hasn't been made?

I would like to schedule a local notification to fire at 7pm everyday IF a certain condition is met (the user hasn't entered daily data).
How do I go about doing this?
Just break it up into 3 cases:
It's before 7pm, and the user hasn't entered their daily data yet
It's before 7pm, and the user has entered their daily data
It's after 7pm
In case 1, you set up a notification to go off at 7pm today, and then repeat every day.
In cases 2 and 3, you set up a notification to go off at 7pm tomorrow, and then repeat every day.
The code to create and schedule the notification looks like this:
UILocalNotification *dailyNotification = [[UILocalNotification alloc] init];
dailyNotification.fireDate = nextReminderTime; // set this to 7pm today or tomorrow
dailyNotification.timeZone = [NSTimeZone defaultTimeZone];
dailyNotification.repeatInterval = NSDayCalendarUnit;
dailyNotification.soundName = UILocalNotificationDefaultSoundName;
dailyNotification.alertBody = #"You need to enter data for today.";
Of course, if you set up an alert for 7pm today, then the user opens the app and enters data before 7pm, the notification for today needs to be cancelled.
Alternatively (this is what I did in a similar situation), you can cancel all the notifications with [[UIApplication sharedApplication] cancelAllLocalNotifications]; and set them up again from scratch based on the application state every time the app is about to go into the background (i.e., in UIApplication applicationDidEnterBackground:. This is simpler since you don't have to think about what notifications you set up before.
Scheduling local notifications in iOS is fairly simple - Apple has a good example of how to do it: https://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW13
I'm assuming that the criteria to "enter daily data" is happening in your app, right? If so, then you'll basically just schedule local notifications for 7PM each day, and then if a user does enter daily data, you'll just cancel the notification for that day. I've found the local notification scheduling to be a bit finicky, so I would probably cancelAllLocalNotifications and then reschedule them all.
Keep in mind that apps are limited to only being able to have 64 scheduled local notifications at once. So theoretically, you could schedule 64 days into the future (since you're just having one notification per day). I'd be cautious with that though, since it may really annoy users. I'd maybe only do it for a few day or a week at a time, since if they aren't opening the app after a few reminders, they may have lost interest.

UILocalNotification issue with past dates

I am making a reminder app, if there aren't a million out there.
I let the user specify a time to remind him of a to-do task.
So lets say the user specifies that he needs to be reminded at 9:00am every Monday.
When he closes the app and its goes in the background I create a UILocalNotification fire time.
at 9:00am on next Monday the user gets the notification.
If he launches my app and adds another reminder for some other day/time (not important) and closes my app by clicking on the home button then he gets a notification right away.
This is because the first notification was set to past Monday date
How can I avoid this yet still deliver a notification next monday?
I found this by googling
"If you specify a date that is in the past (or nil) the notification is delivered immediately. "
So, here's what I got from your question:
User makes repeating event for 9:00AM every Monday
You schedule a single local notification for the next occurring Monday at 9:00AM
One Monday at 9:00AM occurs; the users's event fires
User makes another arbitrary event
The users's first event fires, as if it was Monday at 9:00AM, presumably because Monday at 9:00AM has already happened once
In order to resolve this, you want to make sure you're doing both of these things:
Make sure you're releasing the UILocalNotification.
//Manual Memory Management
[yourLocalNotif release];
//Automatic Reference Counting
yourLocalNotif = nil;
Make sure rescheduling your repeating events for the next occurring time.
If this isn't quite what you're looking for, post some code and I'll try and reevaluate :)

How do i create a looping local notification when the user doesn't choose a starting date?

In my application, the user chooses a day (monday-sunday) to set an alarm for and the application sets up a local notification to repeat weekly on this day. How can i get my application to create a looping weekly notification for this day of the week every week?
Use EventKit to create a recurring event.

Is it possible to schedule push notification time ? (iPhone SDK)

I want to schedule push notification after some time or say after 2 days 15 hours. So after 2 days 15 hours a notification will be sent to a device.
Is it possible ? How ??
Since a push notification originates from a server and not the phone itself you can schedule anything the provider makes available. You will have to check with your notification service provider what they make available.
However if you just need to schedule a future alert on the phone itself, you can use the UILocalNotification class. This will just kick off a notification on the device once the timer expires.