ios - Background task or updating location in iphone -
i want make application updates users location remote server in every xx minute, application in background have tried following code
- (void)applicationdidenterbackground:(uiapplication *)application { i=0; uiapplication *app = [uiapplication sharedapplication]; bgtask = [app beginbackgroundtaskwithexpirationhandler:^{ [app endbackgroundtask:bgtask]; bgtask = uibackgroundtaskinvalid; }]; bgtimer = [nstimer scheduledtimerwithtimeinterval:1.0 target:self selector:@selector(backgroundtask:) userinfo:nil repeats:yes]; } -(void)backgroundtask:(nstimer*)timer{ i++; nslog(@"%s %d",__func__,i); } but timer callback stops after around 10 minutes how can make application continuously updates current location server
you're missing background modes key in app's info.plist file:
<key>uibackgroundmodes</key> <array> <string>location</string> </array> this lets app access location services while in background.
but, type of thing has been asked many times, little browsing of other stack overflow questions more information.
here's one read.
Comments
Post a Comment