Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - is Motion Activity Enabled in Settings > Privacy > Motion Activity

If an app requires access to Motion Activity data it asks the user at install. However if the user accidentally answers 'No', then the app will not work.

I am looking for a way to check if the Motion Activity is enabled, so that I can prompt the user to enable if not.

Can someone point me in the right direction code wise please?


Following the info from Doc (Thank you), it seems that Apple do not provide a direct method to check the status of Motion Activity in Privacy. I was able to find out by picking up on the error:-

[stepCounter queryStepCountStartingFrom:[NSDate date]
                                     to:[NSDate date]
                                toQueue:[NSOperationQueue mainQueue]
                            withHandler:^(NSInteger numberOfSteps, NSError *error) {
                                if (error != nil && error.code == CMErrorMotionActivityNotAuthorized) {
                                    // The app isn't authorized to use motion activity support.
}
like image 576
NeilMortonNet Avatar asked Jan 08 '14 20:01

NeilMortonNet


People also ask

Why doesn't my iPhone have motion and Fitness?

To enable it, open the Chipolo app and in the top left corner tap Settings cog icon. Next tap on Permissions and on the next screen enable Motion.

What does motion and Fitness do on an iPhone?

The Motion Fitness app provides class schedules, social media platforms, fitness goals, and in-club challenges. Our app will also allow you to link many of the popular fitness tracking devices and fitness apps on the market.


2 Answers

Apple has a sample project that shows how to check and request access for all the various permissions (including Motion Activity) here. I suggest you take a quick look at that - it's pretty straightforward.

like image 186
Doc Avatar answered Oct 20 '22 01:10

Doc


New in iOS 9, CMSensorRecorder(doc link) has a class method to check if your app is authorized for Motion & Fitness:

  • Switft class func isAuthorizedForRecording() -> Bool
  • Objective-c + (BOOL)isAuthorizedForRecording
like image 32
Raymond Avatar answered Oct 20 '22 00:10

Raymond