I am scheduling UILocalNotifications in my project. At present I am scheduling the notification for the daily basis. Now the client has asked to do particular scenarios like scheduling for every second week. Is there a way to do this? Please can any one suggest a solution.
Thanks In Advance
The answer provided here can be adjusted to suit your needs.
Changing localNotification.repeatInterval = NSDayCalendarUnit; to localNotification.repeatInterval = NSWeekCalendarUnit; (after extracting it out using NSDateComponents) will be a start.
Use Ekeventkit store to show alert on particular dates/days etc.
You should go through Apple documentation
Related
I have to added a local notification for next 30 days(June-01-2013 t0 June-30-2013).
For Example:
I have to change the date on the "settings" to June-15-2013, and then I have to change the date to June-05-2013. The local notification not called for the (June-01 to June-15). After June-16 is working fine.
My question is
1) Any restrictions for the UILocalNotification to fire the past dates?
2) Is it possible to fire the local notification for past dates?
Please help me. Thanks in advance.
Apple docs states that
If the specified value is nil or is a date in the past, the
notification is delivered immediately.
So if you are setting the fireDate of a local notification in the past the notification will be fired immediately.
Also your case I think is a special one because you are manually change the device date settings. The date settings may be changed when the time zone is changed but your case is different, you are not changing the time zone, you just change the date and I think the local notifications before (in the past) your new date are ignored.
Well, this is one of the situation i had faced when cam testing of robustness of the app. My app was also issuing notification for future dates. All goes well, if user does not change the date. But as part of testing, changing date to future and then past makes disables some notification which were suppose to appear.
The way i workaround this situation was responding to following call back in application Delegate
-(void)applicationSignificantTimeChange:(UIApplication *)application
Here i re-issued all the notifications as per required from the current date. That did the trick in my case. It's a heavy solution as all notifications has to be deleted and re-issued, but did the required for me.
There is one more case where you may required to re-Sync the notification. User may had also changed the date, when app is closed. For this, i made the application to reSync the notification everytime it launches. You can optimize this approach, by checking if there is significant change in date or not.
I would like to create a notifciation that occurs every time a new day has occurred locally (either while using the app, or if it occurs in between launches). I was wondering what might be the best way to go about observing this change.
While your app is running, you can listen for the UIApplicationSignificantTimeChangeNotification notification and test the current day when you receive that. When your app quits, you can save the current day to your preferences, and when the app launches again, you can test the saved day against the current day.
You can get information about the current day using NSDateComponents.
As mentioned in the other thread, as of iOS8, you can also directly listen to NSCalendarDayChangedNotification.
Check out :
Erica Sadun Time Utililties
There are some useful methods there for checking dates.
Alternatively you can look at UILocalNotifcations
You could schedule a local notification with a repeatInterval of one day.
It all depends on what you want to do but those are some options.
I'd probably do two things:
While the app is running, have an NSTimer set to poll the current date [NSDate date] at a given interval. Store the value of the last date someplace (even in the user defaults) and then compare the new time to the stored time to check for a new day.
When closing/quitting the app, store the current date and time in the same manner above. Then, when launching the app or bringing it to the foreground, check the current date against the stored date.
NSDateComponents, NSCalendar and NSDate will come in handy for this.
I have a local notification that I would like to fire every 5 minutes. I use:
localNotif.repeatInterval = NSMinuteCalendarUnit
that will have the notification happen once every minute. I can't figure out how to get this to happen every 5 minutes or whatever other >1 minutes interval. I've tried:
localNotif.repeatInterval= 5 * NSMinuteCalendarUnit
and that doesn't work. Can anyone help me to solve this problem.
Check out this blog http://useyourloaf.com/blog/2010/9/13/repeating-an-ios-local-notification.html
Has a tutorial on how to repeat notifications with an xcode project.
Also maybe it is worth using
NSLog(#"Count: %i", [[[UIApplication sharedApplication] scheduledLocalNotifications] count]);
To check how many notifications your app has registered?
jissa you can't set a 5 minute interval by doing a 5 * NSMinuteCalendarUnit. The current implementation of UILocalNotification does not allow you to fine tune the interval. So you're stuck with every second, every minute, every hour, every day, every week, every month... etc etc.
I've filed a bug report/enhancement at http://bugreport.apple.com/
You may take a look at my report archived at Open Radar: http://openradar.appspot.com/radar?id=759402
According to Marco, developer of Instapaper, Apple prioritizes enhancement and feature requests partly based on how many developers are requesting them.
If this feature is important to you I urge you to file a report as well.
I'm using LocalNotication to set schedule Alarm. atribute repeatInterval allow me to set repeat each minute, each hour.. But I want to set repeat each two minutes? How can i do?
try looking at this blog posting
http://useyourloaf.com/blog/2010/9/13/repeating-an-ios-local-notification.html
You can schedule 30 alarms. One for each 2nd minute for a whole hour, and set repeatInterval to each hour fo each of the 30 notifications.
I've filed a bug report/enhancement at http://bugreport.apple.com/
You may take a look at my report archived at Open Radar: http://openradar.appspot.com/radar?id=759402
According to Marco, developer of Instapaper, Apple prioritizes enhancement and feature requests partly based on how many developers are requesting them.
If this feature is important to you I urge you to file a report as well.
I'm trying to implement local notifications for a calendar-esque application, and I've hit a barrier with reminder intervals. Local notifications seem to only take NSCalendarUnit constants as repeat intervals ( see http://developer.apple.com/iphone/library/documentation/iPhone/Reference/UILocalNotification_Class/Reference/Reference.html#//apple_ref/occ/instp/UILocalNotification/repeatInterval ), as opposed to the typical NSTimeInterval value.
The application that I'm trying to develop would be severely restricted if I'm limited to NSCalendarUnit constants ( which are listed here: http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSCalendar_Class/Reference/NSCalendar.html#//apple_ref/doc/c_ref/NSCalendarUnit ). Is there any way that I can set custom time intervals in a local notification?
You have to schedule multiple LocalNotifications separated by your time frame, until they fix that bug. I am pretty sure I saw that someone filed it as a bug in the Apple Developer forums