Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Posting location updates in background from iOS4

Can i send location updates to my server in background from iOS4?. I want to get users location changes and post it to a server using a web-service call. Main question here is, is it possible to call a web-service or http-post while app is in background?

like image 941
sach Avatar asked Jul 28 '11 10:07

sach


2 Answers

Absolutely, and you may want to review this earlier thread when I asked the same question - credit due to @RedBlueThing for providing the key information.

I've written this up as an example on our blog as well. The key to this working is beginBackgroundTaskWithExpirationHandler: without that you won't get reliable results as it will perhaps work some of the time, but not others.

like image 101
Roger Avatar answered Sep 28 '22 16:09

Roger


Yes. You can basically do anything you want in the background callbacks.

I'd like to add that you should make sure you are aware of the possible impact on battery life, as the antennas may have to be turned on to perform your requests. Perhaps you could store the locations in core data, and post it to the server when the app resumes.

But there's no technical reasons to not do it, and afaik it will pass review too.

like image 39
August Lilleaas Avatar answered Sep 28 '22 16:09

August Lilleaas