1

After searching for some time, I found a few links that were helpful and went with this partial solution for my needs: http://mobileoop.com/getting-location-updates-for-ios-7-and-8-when-the-app-is-killedterminatedsuspended

So you can better understand my needs I will explain them here. What I need to do is send to my backend the user location from time to time (usually every minute). These locations must be sent also when the app is running in background and when the user terminates the app.

By following the above link, my app was able to send locations for only a period of time before the iOS terminated my app. The following text was printed in my phone log.

BKNewProcess: 0x14554b60; my.app.bundle.id; pid: 1539; hostpid: -1> has active assertions beyond permitted time: {( BKProcessAssertion: 0x14558a80> id: 1539-3EF171FD-FFAD-4E67-9CE6-1D615E9479AD name: Called by MyApplication, from -[BackgroundTaskManager beginNewBackgroundTask] process: BKNewProcess: 0x14554b60; my.app.bundle.id; pid: 1539; hostpid: -1> permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:1539 preventSuspend preventIdleSleep preventSuspendOnSleep , BKProcessAssertion: 0x14658370> id: 1539-AA198F96-D8F4-4323-ABC2-E4447D9A4C87 name: Called by MyApplication, from -[BackgroundTaskManager beginNewBackgroundTask] process: BKNewProcess: 0x14554b60; my.app.bundle.id; pid: 1539; hostpid: -1> permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:1539 preventSuspend preventIdleSleep preventSuspendOnSleep )}

So my question is: Is this the correct approach? If so, what could I be doing wrong?

  • Background tasks are terminated after they run for 3 minutes (this is by default and cannot be changed). Also, have you looked here: http://stackoverflow.com/questions/6347503/how-do-i-get-a-background-location-update-every-n-minutes-in-my-ios-application – Glorfindel May 12 '15 at 20:18
  • @Glorfindel, the thing is, my app sends positions for more than 3 minutes before it is shut down by the OS. I've just tested it and the positions received from my server go from 9:55 to 10:03, which is close to 8 minutes. – Pedro Yusim May 13 '15 at 13:14
  • Is that if the user starts your app and leaves it without killing the app? That would make sense, the app will continue to receive location updates indefinitely (e.g. navigation apps work this way). However, when the app is started from the background (by an external event, such as a significant location change), this might work differently. – Glorfindel May 13 '15 at 13:18
  • Yes, this behavior is for when the user does not kill the app. The thing is it stops after some undetermined time. And the only external event my app is listening to is for region monitoring, which I create every N minutes around the user with a radius of 50 meters so I will be able to wake up the app when the user is on the move and has killed the app. – Pedro Yusim May 13 '15 at 13:41

0 Answers0