ios - Local Notifications Call Separate Method -


i'm trying fire local notification on repeated intervals, want call method every time notification sent. possible?

uilocalnotification *localnotif = [[uilocalnotification alloc] init]; if (localnotif == nil) return;  //repeat every 60 seconds nsdate *firetime = [[nsdate date] datebyaddingtimeinterval:60];   localnotif.firedate = firetime; localnotif.alertbody = @"notification sent!"; //send notification localnotif.repeatinterval=kcfcalendarunitminute; [[uiapplication sharedapplication] schedulelocalnotification:localnotif];  //call method?? 

i want call method:

-(void) callaftersixtysecond {     //do } 

yes , no. if app active when notification fires application:didreceivelocalnotification: called in app delegate , use call method. however, if app in background method won't called unless user launches app tapping on notification in notification center, , won't when notification first fires.

one way schedule method separately following:

[self performselector:@selector(callaftersixtysecond) withobject:nil afterdelay:60]; 

this work long app still has processing time when method should run. if user has closed app has around 10s of processing time in same cases can increased starting background task (see beginbackgroundtaskwithname:expirationhandler: in uiapplication).


Comments