2

I am using the following code from the Privacy Prompts project to get the Motion Permission.

- (void)requestMotionAccessData {
    self.cmManager = [[CMMotionActivityManager alloc] init];
    self.motionActivityQueue = [[NSOperationQueue alloc] init];
    [self.cmManager startActivityUpdatesToQueue:self.motionActivityQueue withHandler:^(CMMotionActivity *activity) {
        /* 
         * Do something with the activity reported
         */

        NSLog(@"requestMotionAccessData");
        [self alertViewWithDataClass:Motion status:NSLocalizedString(@"ALLOWED", @"")];
        [self.cmManager stopActivityUpdates];
    }];
}

What if user not allow the motion permission. Do i get some callback? If not is there an alternative way to get the this. I want the callback when user selects Allow or Don't Allow

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Madu
  • 4,849
  • 9
  • 44
  • 78

1 Answers1

2

you just can ... picking 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.
}

from here: iOS - is Motion Activity Enabled in Settings > Privacy > Motion Activity

Community
  • 1
  • 1
TonyMkenu
  • 7,597
  • 3
  • 27
  • 49