2

I am trying to read accelerometer data for indefinite time when the app is in background. By default apple only provides 3 minutes to run any task in background.

I read many post on stack regarding this. All suggested either to use background modes such as Location, Audio etc or use timer. But at same time there are chances of app getting rejected using these techniques as either they are directly not required in my app or are a hack.

I just need to read accelerometer data and store locally. Is there any way to do this without risk of app getting rejected.

Rohit Jain
  • 81
  • 1
  • 7

1 Answers1

0

Turn on background modes for location in capabilitesenter image description here

Refer to hannes comment! on this How Nike+ GPS on iPhone receives accelerometer updates in the background?

There is always a chance of rejection but refer this link may be you will need to provide a disclamer

Community
  • 1
  • 1
Anand Yadav
  • 479
  • 5
  • 17
  • Thank you for the reply. Can I use audio background mode instead of location. As I think using location will require user permission and I don't want to show an extra permission popup to user for the functionality which is not there directly and is just there as a helper to other functionality. – Rohit Jain May 11 '17 at 08:02
  • Audio would technically probably work, but as long as you have no reason to really play audio in the background, your app would be rejected. – Gerriet May 11 '17 at 08:04
  • @Gerriet yes in that case location updates in background mode will be the best bet. – Anand Yadav May 11 '17 at 08:27
  • @RohitJain you have to use location updates in background mode, please refer the image i attached with the answer – Anand Yadav May 11 '17 at 08:34
  • @AnandYadav I tried the solution you suggested. I am calling a startAccelerometerUpdates after locationManager.startUpdatingLocation(). But not getting accelerometer data – Rohit Jain May 11 '17 at 09:12
  • @RohitJain [refer](http://stackoverflow.com/questions/27768689/how-do-i-retrieve-accelerometer-data-correctly-with-swift-in-ios) – Anand Yadav May 11 '17 at 09:34
  • @AnandYadav doing this only. working in foreground, not working in background – Rohit Jain May 11 '17 at 09:40
  • @RohitJain did you enable backgroud mode for location? – Anand Yadav May 11 '17 at 10:22