ios - 用户不允许权限时的 CMMotionActivityManager 回调

标签 ios core-motion cmmotionmanager

我正在使用 Privacy Prompts 项目中的以下代码来获取 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];
    }];
}

如果用户不允许 Action 权限怎么办。我会得到一些回调吗? 如果没有,是否有其他方法可以获取此信息。当用户选择 AllowDon't Allow

时,我想要回调

最佳答案

你可以...挑选错误:

[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

关于ios - 用户不允许权限时的 CMMotionActivityManager 回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24286510/

相关文章:

ios - 使用CCMenuItemImage在hud层中创建单个按钮

augmented-reality - CMMotionData 到 SceneKit SCNNode 方向

ios - CMMotionManager不提供任何值

ios - 我可以在 linux 上开发 ios 应用程序的后端部分吗?

ios - 从 View 中删除 UINavigationBar

ios - 是否可以获取 iOS 用户当前的 healthkit 状态?

iOS 12.2 : CMMotionManager is blocking the main thread

ios - 检测碰撞运动

javascript - 为谷歌搜索结果触发 webViewDidFinishLoad

iphone - 核心运动(相对旋转)