I am using Core Motion Framework for detecting the device activity.
i.e. Walking, Running, Automotive, Stationary
The main issue is i am able to detect walking and running with great accuracy but my device is not able to detect the Automotive mode.
Here is my code
var motionActivityManager: CMMotionActivityManager?
if CMMotionActivityManager.isActivityAvailable() {
motionActivityManager?.startActivityUpdatesToQueue(NSOperationQueue.currentQueue()!, withHandler: {
activityData
in
if activityData!.walking == true {
self.lblActivityStatus?.text = "Walking"
} else if activityData!.running == true {
self.lblActivityStatus?.text = "Running"
} else if activityData!.automotive == true {
self.lblActivityStatus?.text = "Automotive"
} else if activityData!.stationary == true {
self.lblActivityStatus?.text = "Stationary"
}
print("Activity Data: ", activityData)
})
}
I finally got the answer by testing the same app on multiple devices. the m7 chip on first generation device is not working properly for particularly "Automotive" mode. When i was testing on 5s and ipad air, it was not detecting Automotive mode as it should detect. But testing the same app with iphone 6 Plus, it worked fine. so the problem was with device not with framework.