【问题标题】:CMMotionActivityManager callback when user not allow the permisson用户不允许权限时的CMMotionActivityManager回调
【发布时间】:2014-06-18 13:11:52
【问题描述】:

我正在使用来自隐私提示项目的以下代码来获取运动权限。

- (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];
    }];
}

如果用户不允许移动权限怎么办。我得到一些回调吗? 如果没有,是否有其他方法可以得到这个。当用户选择AllowDon't Allow 时,我想要回调

【问题讨论】:

    标签: ios core-motion cmmotionmanager


    【解决方案1】:

    你可以...选择错误:

    [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.
    }
    

    从这里:iOS - is Motion Activity Enabled in Settings > Privacy > Motion Activity

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多