Coremotion Updates in Background State

Receive accelerometer updates in background using CoreMotion framework

You can not only use accelerometer for fetching data from background,

And as you say your App registers for location updates , start location manager in the foreground.

Implementing Long-Running Background Tasks

For tasks that require more execution time to implement, you must request specific permissions to run them in the background without their being suspended. In iOS, only specific app types are allowed to run in the background:

  1. Apps that play audible content to the user while in the background, such as a music player app
  2. Apps that record audio content while in the background.
  3. Apps that keep users informed of their location at all times, such as a navigation app
  4. Apps that support Voice over Internet Protocol (VoIP)
  5. Apps that need to download and process new content regularly
  6. Apps that receive regular updates from external accessories

Is it possible to obtain gyroscope data updates when app is in the background

Have a look at this question.

It looks like you can't get data from CoreMotion without some other background activity like Background Audio or GPS tracking.
From my experience, both of those modes will allow you to execute code in the background.

EDIT:
Using BLE, make sure to send data over Bluetooth from time to time to keep iOS from suspending your app for inactivity.

iPhone collecting CoreMotion data in the background. (longer than 10 mins)

Use this one:

Apps that keep users informed of their location at all times, such as a navigation app

In other words, you make a location manager and tell it to start doing updates. You don't have to do anything with those updates! But as long as this is happening - that is, as long as your app is continuing to do location updates in the background - your app is also allowed to use Core Motion in the background. This is not just a trick; it is official Apple policy as explained in one of the WWDC videos from a couple of years ago.



Related Topics



Leave a reply



Submit