ios - how to call a method by using nstimer in background state -
i want fetch service every 15 mins,so using nstimer.it working fine.but how call same service while app in background state using nstimer.nstimer not working in background state.please suggest me.
//when application move active inactive state.
- (void)applicationwillresignactive:(uiapplication *)application { [self sendbackgroundlocationtoserver]; } - (void) sendbackgroundlocationtoserver { uibackgroundtaskidentifier bgtask = uibackgroundtaskinvalid; bgtask = [[uiapplication sharedapplication] beginbackgroundtaskwithexpirationhandler:^{ [[uiapplication sharedapplication] endbackgroundtask:bgtask]; }]; //start timer [self starttimer]; //close task if (bgtask != uibackgroundtaskinvalid) { [[uiapplication sharedapplication] endbackgroundtask:bgtask]; } }
Comments
Post a Comment