objective c - How do I get a background location update every n minutes in my iOS application? -


i'm looking way background location update every n minutes in ios application. i'm using ios 4.3 , solution should work non-jailbroken iphones.

i tried / considered following options:

  • cllocationmanager startupdatinglocation/startmonitoringsignificantlocationchanges: works in background expected, based on configured properties, seems not possible force update location every n minutes
  • nstimer: work when app running in foreground doesn't seem designed background tasks
  • local notifications: local notifications can scheduled every n minutes, it's not possible execute code current location (without user having launch app via notification). approach doesn't seem clean approach not notifications should used for.
  • uiapplication:beginbackgroundtaskwithexpirationhandler: far understand, should used finish work in background (also limited in time) when app moved background rather implementing "long-running" background processes.

how can implement these regular background location updates?

i found solution implement of apple developer forums:

  • specify location background mode
  • create nstimer in background uiapplication:beginbackgroundtaskwithexpirationhandler:
  • when n smaller uiapplication:backgroundtimeremaining work fine. when n larger, location manager should enabled (and disabled) again before there no time remaining avoid background task being killed.

this works because location 1 of 3 allowed types of background execution.

note: lost time testing in simulator doesn't work. however, works fine on phone.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -