Is there any provision where I can access accelerometer sensor values from apple watch to iPhone when Apple watch-app is in background?

We want to use apple watch as a device and simulate its motion on the iPhone based on accelerometer values,


Project Flow :

  1. We have created a single view Application iPhone app
  2. Added Apple Watch target
  3. Got values of the accelerometer(x, y, and z) in Apple Watch app using CoreMotion framework
  4. We store those value in Dictionary
  5. We send Dictionary using WatchConnectivity
  6. Received accelerometer(x, y, and z) values in the iPhone App



Detail Development :


We are getting accelerometer values using the following method,

open func startAccelerometerUpdates(to queue: OperationQueue, withHandler handler: @escaping CMAccelerometerHandler)


After getting these accelerometer(x , y and z) values we are sending it iPhone app using

func updateApplicationContext(_ applicationContext: [String: Any]) throws


Problem Faced:

We are getting accelerometer sensor values only when the Apple Watch app is in the foreground state, once Apple Watch App goes in background state no data received.

Replies

As of a few years ago the only way a non-Apple app can keep receiving accelerator values was to stay in the foreground by starting a workout session (HKWorkoutSession, startWorkoutSession) and keep the workout session going. This keeps your app in the foreground and is a real drain on the battery (i.e. heartrate monitor light continues to shine). I do not think there there is any other way - but I could be wrong.

>Problem Faced:

We are getting accelerometer sensor values only when the Apple Watch app is in the foreground state, once Apple Watch App goes in background state no data received.


You might want to file a bug, but I expect the come back would be 'operates as expected'.


Still, if you have a use case you can still file an enhancement request via the bug reporter, link below, adding your report # to your thread for reference, thanks and good luck.