当前位置: 首页 > news >正文

有没有可以做兼职的网站吗织梦游戏网站源码

有没有可以做兼职的网站吗,织梦游戏网站源码,漯河网站建设xknt,自己可以开发一个软件吗文章目录 一、简介二、权限配置1. 在开发者账号中勾选HealthKit2. 在targets的capabilities中添加HealthKit。3. infoPlist需要配置权限 三、创建健康数据管理类1. 引入头文件2. 健康数据读写权限3. 检查权限4. 读取步数数据5. 写入健康数据 四、运行获取权限页面 一、简介 He… 文章目录 一、简介二、权限配置1. 在开发者账号中勾选HealthKit2. 在targets的capabilities中添加HealthKit。3. infoPlist需要配置权限 三、创建健康数据管理类1. 引入头文件2. 健康数据读写权限3. 检查权限4. 读取步数数据5. 写入健康数据 四、运行获取权限页面 一、简介 HealthKit是一款用于搜集和办理医疗和健康相关数据的开发工具包它为开发者供给了拜访用户健康数据的API和框架并使得这些数据能够与iOS设备上的其他应用程序相互共享。 HealthKit允许应用程序搜集和办理各种类型的健康数据包含身体丈量数据如体重、身高和心率、健身数据如步数和距离、饮食数据、睡觉数据和心理健康数据等。这些数据能够从多个来历搜集如从硬件设备如智能手表、智能手机和健身跟踪器中获取或由用户手动输入。 二、权限配置 1. 在开发者账号中勾选HealthKit 2. 在targets的capabilities中添加HealthKit。 3. infoPlist需要配置权限 Privacy - Health Share Usage Description 需要您的同意才能访问健康更新给您带来更好的服务 Privacy - Health Update Usage Description 需要您的同意才能分享健康数据给您带来更好的服务 注意iOS13 这里描述太粗糙会导致程序崩溃。 三、创建健康数据管理类 1. 引入头文件 import HealthKit2. 健康数据读写权限 // 写权限private func dataTypesToWrite() - SetHKSampleType {// 步数let stepCountType HKObjectType.quantityType(forIdentifier: .stepCount)// 身高let heightType HKObjectType.quantityType(forIdentifier: .height)// 体重let weightType HKObjectType.quantityType(forIdentifier: .bodyMass)// 活动能量let activeEnergyType HKObjectType.quantityType(forIdentifier: .activeEnergyBurned)// 体温let temperatureType HKObjectType.quantityType(forIdentifier: .bodyTemperature)// 睡眠分析let sleepAnalysisType HKObjectType.categoryType(forIdentifier: .sleepAnalysis)let setTypes Set([stepCountType, heightType, weightType, activeEnergyType, temperatureType, sleepAnalysisType].compactMap { $0 })return setTypes}// 读权限private func dataTypesToRead() - SetHKObjectType {// 步数let stepCountType HKObjectType.quantityType(forIdentifier: .stepCount)// 身高let heightType HKObjectType.quantityType(forIdentifier: .height)// 体重let weightType HKObjectType.quantityType(forIdentifier: .bodyMass)// 体温let temperatureType HKObjectType.quantityType(forIdentifier: .bodyTemperature)// 出生日期let birthdayType HKObjectType.characteristicType(forIdentifier: .dateOfBirth)// 性别let sexType HKObjectType.characteristicType(forIdentifier: .biologicalSex)// 步数跑步距离let distance HKObjectType.quantityType(forIdentifier: .distanceWalkingRunning)// 活动能量let activeEnergyType HKObjectType.quantityType(forIdentifier: .activeEnergyBurned)// 睡眠分析let sleepAnalysisType HKObjectType.categoryType(forIdentifier: .sleepAnalysis)let setTypes Set([stepCountType, heightType, weightType, activeEnergyType, birthdayType, sexType, distance, temperatureType, sleepAnalysisType].compactMap { $0 })return setTypes}3. 检查权限 /// 检查是否支持获取健康数据public func authorizeHealthKit(_ compltion: ((_ success: Bool, _ error: Error?) - Void)?) {guard HKHealthStore.isHealthDataAvailable() true else {let error NSError(domain: 不支持健康数据, code: 2, userInfo: [NSLocalizedDescriptionKey: HealthKit is not available in th is Device])if let compltion compltion {compltion(false, error)}return}let writeDataTypes dataTypesToWrite()let readDataTypes dataTypesToRead()healthStore.requestAuthorization(toShare: writeDataTypes, read: readDataTypes) { success, error inif let compltion compltion {compltion(success, error)}}}4. 读取步数数据 /// 获取步数public func getStepCount(_ completion: escaping ((_ stepValue: String?, _ error: Error?) - Void)) {// 要检索的数据类型。guard let stepType HKObjectType.quantityType(forIdentifier: .stepCount) else {let error NSError(domain: 不支持健康数据, code: 2, userInfo: [NSLocalizedDescriptionKey: HealthKit is not available in th is Device])completion(nil, error)return}// NSSortDescriptors用来告诉healthStore怎么样将结果排序。let start NSSortDescriptor.init(key: HKSampleSortIdentifierStartDate, ascending: false)let end NSSortDescriptor.init(key: HKSampleSortIdentifierEndDate, ascending: false)/*param sampleType 要检索的数据类型。param predicate 数据应该匹配的基准。param limit 返回的最大数据条数param sortDescriptors 数据的排序描述param resultsHandler 结束后返回结果*/let query HKSampleQuery.init(sampleType: stepType, predicate: HealthKitManager.getStepPredicateForSample(), limit: HKObjectQueryNoLimit, sortDescriptors: [start, end]) { _, results, error inguard let results results else {completion(nil, error)return}print(resultCount \(results.count) result \(results))// 把结果装换成字符串类型var totleSteps 0results.forEach({ quantitySample inguard let quantitySample quantitySample as? HKQuantitySample else {return}let quantity quantitySample.quantitylet heightUnit HKUnit.count()let usersHeight quantity.doubleValue(for: heightUnit)totleSteps Int(usersHeight)})print(最新步数\(totleSteps))completion(\(totleSteps), error)}healthStore.execute(query)}5. 写入健康数据 /// 写入数据public func writeStep() {let steps HKObjectType.quantityType(forIdentifier: .stepCount)!let quantity HKQuantity(unit: HKUnit.count(), doubleValue: 1000)let now Date()let start now.addingTimeInterval(-3600 * 24)let end nowlet sample HKQuantitySample(type: steps, quantity: quantity, start: start, end: end)let healthStore HKHealthStore()healthStore.save(sample) { (success, _) inif success {// 数据已写入 HealthKit} else {// 写入数据失败}}}四、运行获取权限页面
http://www.yutouwan.com/news/374027/

相关文章:

  • 孝感建设银行网站知名网站开发语言
  • 深圳国税局深圳做网站公司做程序的软件
  • 网站开发颜色江西宣传片制作公司
  • 网站搭建收费参考常见网站结构有哪些
  • 关于网站开发的期刊做企业网站好处
  • 站长之家官网查询便宜的seo网站优化排名
  • 快照打开是网站网站网站绑定公众号
  • 网站建设与维护教程南开网站建设公司
  • 个人博客手机网站模板seo排名点来上海百首网络
  • 自己做的网站怎么取sql数据怎么进入wordpress的后台
  • 网站搜索排名优化价格网站建设 0551
  • 深圳网站建设公司的英文名是网上购物软件排行榜
  • 上海网站建设中淘客推广方法
  • 江阴市建设局官网站建设工程规范在哪个网站发布
  • 网站卡片设计网上接做网站的单子
  • 好的建设网站成都龙泉工程建设有限公司网站
  • 徐州网站建设 和信网站在线演示
  • 做网站时搜索的代码是什么针对315老坛酸菜企业解决方案
  • 杭州学网站建设免费隐私网站推广app
  • 加盟网站模板安居客网站应该如何做
  • 广州网站制作培训做网站的感想
  • 北京手机网站设计费用个人备案网站放什么手续
  • 大庆建设大厦网站小程序账号申请
  • 查网站注册信息菲律宾离中国多远
  • 可以做长图的网站前端面试题2022
  • 腾讯轻量应用服务器建站模板邯郸学校网站建设报价
  • 阿里云1核2g服务器能建设几个网站电子政务与网站建设意义
  • 网站设计公司-信科网络软件开发工程师需要什么证书
  • 珠海企业落户申请网站天坛装修公司口碑怎么样
  • 国外用python做的网站南京开发app的公司