ios 健康数据代码怎么防止作弊

请问下,ios 健康数据代码怎么防止作弊
最新回答
-她滥我情

2024-09-22 07:23:40

#pragma mark - 获取步数从HealthKit
- (void)getstepCountFromHealthKit
{
HKQuantityType *type = self.items[5];
//这个函数是获取苹果健康里面的全部步数包括人为添加的
[self fetchQuantity:typecompletionHandler:^(NSArray *result,NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error)
{
//从苹果健康获取步数失败
NSLog(@"error:%@",error);
[PersonInfo sharePersonInfo].isAllow = NO;
}
else if ([resultcount] == 0)
{
//没有步数
[PersonInfo sharePersonInfo].isAllow = YES;
}
// succeeded to retrieve the health data
else
{
[PersonInfo sharePersonInfo].isAllow = YES;
//这个函数是去除人为添加的,留下系统记录的步数
NSArray *array = [selfgetRealHealthData:result];

//统计数组里面的步数
NSInteger allArrStepCount = 0;
//一个数组的添加
for (NSDictionary *dictin array)
{
NSInteger stepCount = [dict[@"stepCount"]integerValue];
allArrStepCount = allArrStepCount + stepCount;
NSString *dateTime = dict[@"dateTime"];
[_dateTimeArr addObject:dateTime];