I'm creating an app that uses CMDeviceMotion to collect gyroscope and accelerometer data from the watch and phone respectively. The data collection should be able to last continuously for about 10 minutes. Problem is, the collection stops whenever the screen goes black. What would be the best way to make sure the collection continues in sleep mode? Can I collect data from these sensors in a HKWorkoutSession?
I'm using XCode version 10.2 and Swift 4.2.