Is there any way of fetching sensors data if watch

2019-08-22 08:31发布

I am working on watch app extension in which I am collecting the data from all sensors (Accelerometer, pedometer, gyroscope, barometer, location, heart rate etc) in maximum of 100HZ frequency, but I am facing problem with sensors stop giving data in following scenarios:

  1. If I drop my arm then sensor works for few seconds after that, sensors do not provide data until I raise my wrist again.
  2. Any point of time code execution stops so that we do not get data.

So I used CMSensorRecorder class but only this class can not fulfil our requirement.

so what is the way to get sensor data independent of active/de-activate state of WKInterfaceController? I have to fetch data if app is in foreground state, either active state or de-active state.

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-08-22 09:23

Background execution is only allowed on watchOS for a period longer than 3minutes when your app is running a Workout. You cannot fetch any sensor data in the background unless your app is running a Workout.

However, as the official App Programming Guide for watchOS states, you shouldn't be running any tasks in the background unless your app is a Workout app, so I'd suggest you to reconsider how your app works.

查看更多
登录 后发表回答