ios - schedule localnotifcation on future date range -
- (void) schedulegeneralnotificationfrequentlywithitem:(todoitem *)item interval:(int)minutesbefore frequent:(nscalendarunit)frequentunit{ nscalendar *calendar = [nscalendar autoupdatingcurrentcalendar]; nsdatecomponents *datecomps = [[nsdatecomponents alloc] init]; [datecomps setday:item.day]; [datecomps setmonth:item.month]; [datecomps setyear:item.year]; [datecomps sethour:item.hour]; [datecomps setminute:item.minute]; nsdate *itemdate = [calendar datefromcomponents:datecomps]; [datecomps release]; uilocalnotification *localnotif = [[uilocalnotification alloc] init]; if (localnotif == nil) return; localnotif.firedate = [itemdate datebyaddingtimeinterval:-(minutesbefore*60)]; localnotif.timezone = [nstimezone defaulttimezone]; if (!item.eventname) { item.eventname = @"my event name"; } localnotif.alertbody = item.alertbody; localnotif.alertaction = nslocalizedstring(@"details", nil); localnotif.soundname = uilocalnotificationdefaultsoundname; localnotif.applicationiconbadgenumber = 1; localnotif.userinfo = item.data; // info localnotif.repeatinterval = frequentunit; // here set nsdaycalendarunit [[uiapplication sharedapplication] schedulelocalnotification:localnotif]; [localnotif release]; nsstring *isdisablelocalpush = [settings getsetting:kpraktijdisablelocalpushkey]; if ([isdisablelocalpush isequaltostring:kjsonvalueyes]) { //disable notifications after added [self disablealllocationpushnotifications]; } }
here in above code, schedule daily till localnotif.firedate , right?
what trying accomplish : schedule notification each day on next 1 month month eg: daily notification 2013/march/01 2013/may/01
no, schedule daily notification starting fire date (until cancel it).
if want schedule date range , not exceed limit of local notification can set @ 1 time (which 64, still less 2 months required), think best schedule local notification 1 1 every day.
just start nsdate object starting fire date, schedule local notification without repeat interval, increment nsdate day, , repeat scheduling local notification until reaches end date of range.
ios localnotification
No comments:
Post a Comment