objective c - Multi UILocalNotification -
hello have problem uilocalnotification. taking notification server store json array in mutable array. :
idnoty * id of notification titlenoty * title of notification
when try code :
uilocalnotification *notif; nsmutablearray *notifications = [[nsmutablearray alloc] init]; for(int i=0 ; i<[idnoty count]; i++){ notif=[[uilocalnotification alloc]init]; if (notif == nil) return; nslog(@" h loop %i",i); notif.firedate = [nsdate date]; notif.timezone = [nstimezone defaulttimezone]; [[uiapplication sharedapplication] cancelalllocalnotifications]; uilocalnotification *localnotification = [[uilocalnotification alloc] init]; [localnotification sethasaction:yes]; localnotification.timezone = [nstimezone localtimezone]; localnotification.alertbody = [titlenoty objectatindex:i]; localnotification.applicationiconbadgenumber = i+1; [[uiapplication sharedapplication] schedulelocalnotification:localnotification ]; } finaly when have 2 , more notifications server. code displaying last notitfication.
json: code
content = ( { active = 1; descr = sdescr; entrydate = "2013-05-15"; id = 48; pid = 11; title = dasdsad; }, { active = 1; descr = sdescr; entrydate = "2013-05-16"; id = 49; pid = 11; title = malaka; }, { active = 1; descr = sdescr; entrydate = "2013-05-16"; id = 50; pid = 11; title = dasdsadsadsadsadsadsadsagdfggffggfdgdfgdfgdfgdfgdfgdfgdfgdf; } ); "total_rows" = 3; } thanks
you should not call [[uiapplication sharedapplication] cancelalllocalnotifications] inside loop every time.
Comments
Post a Comment