UILocalNotification on particular day like sunday repeat by every 2 week - ios

I want to repeat UILocalNotification particular day alternatively. I mean if it's fire on sunday 7:00 am then second notification should be fire on next to next sunday 7:00 am.
Is this possible?
Can any one help me.
Thanks!

You can make a counter of hours's and save it in NSUserDefaults
if (counterOfHours % 336 == 0) then push notification, remember to set counterOfHours to 0 :)
Cheers S.

Related

Ios repeating local notifications

Here are my problems :
Schedule local notifications between two dates every specific day of the week . example : between march 1 and march 20 every sunday
I have more than 64 local notifications to set which is the limit .
For the first problem i know there is repeatIntervals which i can set to fire notification every Sunday but how can i set them between two dates ? Do i need to calculate manually and find all the Sundays between March 1 and 20 and then set it or there is something better ?
Use the NSCalendar to get the specific dates, put in an array, and pass to the scheduleLocalNotification.
In this topic you can have a sample code of how to do it.

How to get the interval value from two UIDatePicker

I have two UIDatePickers. startDatePicker is to choose a start date and endDatePicker is to choose an end date. It should be something like
START: 2015/06/25 11:00
END: 2015/07/06 13:00
->Time Interval: 12 days 2 hours = 1044000 seconds
And the 1044000 seconds is what I want to get here. Just I am not sure how.
I am guessing maybe I can use
startDatePicker.date.timeIntervalSinceDate(endDatePicker.date)
to get the value? If so, what is the necessary settings for the two UIDatePickers?
Or maybe there are other ways to do that? Thanks in advance.

How to schedule local notification varying time slot?

I need to fire a local notification which is decided by the end user.
I provide 8/9 options to the user for selecting at least one of below time duration.
20 minutes , 25 minutes till 60 minutes.
Again user provides the starting time.
Consider the time duration is morning 6.28 to night 11.37
The expected tasks performed by the local notification is
show a local notification after every 20 minutes between the duration of 6.28 am to 11.37 pm.
first notification will come at 6.48 am. And till its 11.37 . No notification should come after 11.37.
Is there any way ?
UILocalNotification has a repeatInterval property which you'd normally use to create recurring notifications. Unfortunately, it does not offer the flexibility you need - you can use repeat intervals of 1 minute, 1 hour, but nothing in between. And there's also no 'end date' option.
The only other option is to create multiple notifications, each firing only once. Keep in mind that there is a maximum of 64 notifications per app. With a minimum interval of 20 minutes, this covers 21 hours and 20 minutes of notifications.
UILocalNotification has repeatInterval property.
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.repeatInterval = NSMinuteCalendarUnit;
Try above code.

Get current date past midnight, Objective C

I want to get the current date, even if the time has passed midnight. Imagine it's friday night the 6th of June 2014 - we check the date Saturday at 2 am, but we still want this to count as being friday. How would I go about this?
Let's just say we cut it at 9am the next day. I.e. we will assume previous date until the time has passed 9 am. Yes, this is software used at a nightclub, as you can imagine.
I guess this would involve something like subtracting 1 day from the current date if the hour is less than 10?
You can use interval to specific date like
[[NSDate date] dateByAddingTimeInterval:interval];
Assuming the cutoff is 9am, all you need to do is create an NSDate that's 9 hours earlier than the actual time.
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:-(9 * 3600)];
That way every day begins and ends at 9am.

Can I set UILocalnotification to repeat every last day of every month?

I want to try this myself, but it would take a month before I can sure it work. Any one have ever try this ?
NSDate *fireDate = // Date I want to repeat, in this case 31 may
localNotification.fireDate = fireDate;
localNotification.repeatInterval = NSMonthCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
I expected it to alert on the last day of every month. Is this a way to go ? And if I schedule it on 30-day month and the next day is 31-day month like April -> May What should I do, because I can only set it to 30 April (also February 28 and 29 day problem)
I got an answer after playing with UILocalNotification for a while, If you want to make it repeat every last day every months just set it to January 31 with repeatInterval NSMonthCalendarUnit and it will repeat every last day of every months

Resources