我正在使用来自隐私提示项目的以下代码来获取运动权限。
- (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];
}];
}
如果用户不允许移动权限怎么办。我得到一些回调吗?
如果没有,是否有其他方法可以得到这个。当用户选择 Allow 或 Don't Allow 时,我想要回调
Best Answer-推荐答案 strong>
你可以...选择错误:
[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/
|