2

I'm developing a navigation app which can run in the background. That's working fine thanks to setting UIAccelerometer to location. But I'd like to use the accelerometer too, to get some additional information about what the user is doing. However, while in the background, the UIAccelerometer doesn't call its delegate.

Is there any way to get the current acceleration while being in the background?

hanno
  • 6,401
  • 8
  • 48
  • 80

2 Answers2

5

I found the solution myself. It is indeed possible to get accelerometer data while running in the background. All one has to do is to rely on the CoreMotion framework rather than on the UIAccelerometer class which, as the name suggests, is a user interface related class.

See this question: How Nike+ GPS on iPhone receives accelerometer updates in the background?

Community
  • 1
  • 1
hanno
  • 6,401
  • 8
  • 48
  • 80
0

NO..you won't be able to get UIAccelerometer values in the background..you can get heading and other types of values specific to core location though..

Shubhank
  • 21,721
  • 8
  • 65
  • 83
  • Do you have a reference/link for that statement? – hanno Feb 20 '12 at 15:29
  • https://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html go through this page..specifically backgroundModes – Shubhank Feb 20 '12 at 15:50
  • I'm sorry but that's just not helpful at all. It does not address my question. – hanno Feb 20 '12 at 16:47
  • well only thing i can tell for certain is you won't be able to get the accelerometer values in background..if you have other doubts do tell. – Shubhank Feb 20 '12 at 16:49
  • Well, an explanation or at least a reference would be helpful. But you don't seem to have either of these. Maybe someone else does. – hanno Feb 20 '12 at 20:28