i'm adding local notifications for
loop, when check how many notifications scheduled [[uiapplication sharedapplication] scheduledlocalnotifications]
shows 1 notification scheduled.
this code:
for (int = ((int)day - 1) * 6; < ((int)day - 1) * 6 + 64; i++) { nslog(@"notification #%d", i); [[uiapplication sharedapplication] cancelalllocalnotifications]; nsdictionary *currentpraytime = [self.praytimes objectatindex:i]; nsdateformatter *dateformatter = [nsdateformatter new]; [dateformatter setdateformat:@"yyyy.mm.dd hh:mm"]; nsdate *datetosetnotification = [dateformatter datefromstring:[nsstring stringwithformat:@"%@ %@", [currentpraytime objectforkey:@"date"], [currentpraytime objectforkey:@"time"]]]; nscalendar *gregorian = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar]; nsdatecomponents *offsetcomponents = [[nsdatecomponents alloc] init]; [offsetcomponents setminute:-10]; nsdate *datebeforepray = [gregorian datebyaddingcomponents:offsetcomponents todate:datetosetnotification options:0]; uilocalnotification *localnotif = [[uilocalnotification alloc] init]; localnotif.firedate = datebeforepray; localnotif.timezone = [nstimezone localtimezone]; localnotif.alertbody = [nsstring stringwithformat:nslocalizedstring(@"%d минут до %@", nil), [[nsuserdefaults standarduserdefaults] integerforkey:@"minutesbefore"], [currentpraytime objectforkey:@"title"]]; localnotif.soundname = uilocalnotificationdefaultsoundname; localnotif.applicationiconbadgenumber = 1; localnotif.userinfo = currentpraytime; [[uiapplication sharedapplication] schedulelocalnotification:localnotif]; }
thanks advance!
edit:
the 1 notification showing last local notification in loop.
please recheck uilocalnotification firedate , should not past date means less current date & time.
localnotif.firedate = datebeforepray; nslog(@"%@",localnotif.firedate);
hope you.
Comments
Post a Comment