I am trying to get background motion updates but as soon as the application goes in background, the motion stops updating. I tried using background mode with audio enabled but got nothing. Any help would be appreciated.
motionManager.startDeviceMotionUpdates(to: OperationQueue.current!) {
(data, error) in
if let trueData = data {
print("\(trueData)")
}
}
motionManager is of type CMMotionManager.
I also tried this in onDisappear()
let session = AVAudioSession.sharedInstance()
do{
var player: AVPlayer = AVPlayer()
try session.setCategory(AVAudioSession.Category.playback)
try session.setActive(true)
self.stopMotionSensors()
self.startMotionSensors()
player.play()
} catch {}