时,我想要回调
我使用以下代码从隐私提示项目获得运动许可。
- (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
你只是可以…选择错误:
[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 -在设置中启用动作活动>隐私比;运动活动