I have written this code which checks the authorization status of CMMotionActivityManager, and whether the user allows my app to access it.
I soon found that this code does in fact work, but only after iOS 11. As you can see, I have left an else statement for fallback code for versions before iOS 11. Does anyone know how I can achieve the same process for versions below iOS 11 and then use that functionality in the else statement? I cannot find much online.
private func checkAuthorizationStatus() {
if #available(iOS 11.0, *) {
switch CMMotionActivityManager.authorizationStatus() {
case CMAuthorizationStatus.denied:
onStop()
// no authorization
default:break
}
} else {
// Fallback code for < iOS 11
}
}
Any help is appreciated.