Question

Our app would like to access accelerometer data in background. A possible way to achieve is to use Core Motion for accelerometer readings -

with

CLLocationManager* locationManager;
CMMotionManager* motionManager;
...
[motionManager startAccelerometerUpdatesToQueue: ... withHandler: ...]

which works fine on the foreground, but the only way I've found to receive the updates in background is to set the app to allow using Location in background, and call

[locationManager startUpdatingLocation] 

in -applicationWillResignActive:

The problem is, when I call startUpdatingLocation that a window pops up with text Turn On Location Services to Allow "app" to Determine Your Location.

But of course, I receive accelerometer readings regardless of whether Location Services are enabled, but the popup is annoying and will probably confuse users.

Is getting accelerometer data in the background somewhat tied to attempting to receive location updates?

Was it helpful?

Solution

You can use startAccelerometerUpdatesToQueue in background, the only thing you need to meet — use any background mode to make you app running in the background (location updates (your case), playback, VoIP or BT4 central).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top