Upgrade to Pro — share decks privately, control downloads, hide ads and more …

About HealthKit nutrition

coe
November 14, 2023

About HealthKit nutrition

potatotips #85 iOS/Android開発Tips共有会

coe

November 14, 2023
Tweet

More Decks by coe

Other Decks in Technology

Transcript

  1. ӫཆͷऔΓํ ͪΌΜͱӫཆΛͱΖ͏ let store = HKHealthStore() // ͱΓ͍ͨӫཆૉΛܾΊΔ let dietaries:

    Set<HKQuantityType> = [ .init(.dietaryEnergyConsumed), .init(.dietaryCarbohydrates), .init(.dietaryProtein), .init(.dietaryMolybdenum), ] // ݖݶΛͱΔ try await store.requestAuthorization(toShare: dietaries, read: dietaries) // อଘ͢Δ try await store.save(HKObject)
  2. ӫཆͷऔΓํ ͪΌΜͱӫཆΛͱΖ͏ let store = HKHealthStore() // ͱΓ͍ͨӫཆૉΛܾΊΔ let dietaries:

    Set<HKQuantityType> = [ .init(.dietaryEnergyConsumed), .init(.dietaryCarbohydrates), .init(.dietaryProtein), .init(.dietaryMolybdenum), ] // ݖݶΛͱΔ try await store.requestAuthorization(toShare: dietaries, read: dietaries) // อଘ͢Δ try await store.save(HKObject)
  3. ͪΌΜͱӫཆΛͱΖ͏ let correlation = HKCorrelation(type: .init(.food), start: .now, end: .now,

    objects: .init(arrayLiteral: HKQuantitySample(type: .init(.dietaryMolybdenum), quantity: .init(unit: .gramUnit(with: .micro), doubleValue: 85), start: .now, end: .now), HKQuantitySample(type: .init(.dietaryEnergyConsumed), quantity: .init(unit: .largeCalorie(), doubleValue: 717), start: .now, end: .now), HKQuantitySample(type: .init(.dietaryCarbohydrates), quantity: .init(unit: .gram(), doubleValue: 112), start: .now, end: .now), HKQuantitySample(type: .init(.dietaryProtein), quantity: .init(unit: .gram(), doubleValue: 18), start: .now, end: .now)), metadata: [HKMetadataKeyFoodType: "ڇက"]) try await store.save(correlation) ),$PSSFMBUJPOͰؔ࿈෇͚
  4. w ࢷ࣭ w ̏େӫཆૉͷҰͭ w ೔ຊͰ͸දࣔٛ຿͋Γ w )FBMUI,JUʹ͸ࢿ࣭ͱ͍͏߲໨߲໨ͳ͠ w EJFUBSZ'BU5PUBM

    ૯ࢷ๱ ͱͯ͠ొ࿥͢Δ w ૯ࢷ๱͸৯඼ʹؚ·ΕΔࢷ࣭ͷ૯ྔΛද͍ͯ͠Δ w ࢷ࣭ͷ಺༁ʹ֤छࢷ๱ࢎؚ͕·ΕΔ ஫ҙ͢΂͖ӫཆૉ ͪΌΜͱӫཆΛͱΖ͏
  5. w ৯Ԙ૬౰ྔ w ೔ຊͰ͸දࣔٛ຿͋Γ w )FBMUI,JUʹ͸߲໨ͳ͠ w φτϦ΢Ϝ EJFUBSZ4PEJVN ͔Βࢉग़Մೳ

    w EJFUBSZ4PEJVN NH  ৯Ԙ૬౰ྔ ஫ҙ͢΂͖ӫཆૉ ͪΌΜͱӫཆΛͱΖ͏
  6. w ফඅऀி w ӫཆ੒෼දࣔʹ͍ͭͯ w IUUQTXXXDBBHPKQQPMJDJFTQPMJDZGPPE@MBCFMJOHOVUSJFOU@EFDMFBSBUJPO w ӫཆ੒෼දࣔΛ࢖ͬͯɺ͋ͳͨ΋৯ԘઁऔྔΛݮΒͤΔ w IUUQTXXXDBBHPKQQPMJDJFTQPMJDZGPPE@MBCFMJOHIFBMUI@QSPNPUJPOQEG

    GPPE@MBCFMJOH@DNT@@QEG w ಺ֳ෎ϗʔϜϖʔδ w ӫཆ੒෼දࣔݕ౼ձใࠂॻ w IUUQTXXXDBPHPKQDPOTVNFSIJTUPSZLBCVTPTIJLJPUIFSNFFUJOH EPD@TBOLPVQEG ࢀߟαΠτ ͪΌΜͱӫཆΛͱΖ͏