Can I add custom data to HealthKit?

We are creating an application that collects a special type of data that is not supported by the list in the Health application. Is there a way to create a new category for this?


source to share

2 answers

No, not at this time. From the HealthKit Framework Reference :

The HealthKit framework is for sharing data between apps. For this purpose, the structure contains data types and units in a predefined list. These restrictions ensure that other applications understand what the data means and how it can be used. As a result, developers cannot create their own data types or units . Instead, HealthKit tries to provide a fairly comprehensive list of data types and units.

If I were you, I would put a radar ( ) that details the type of health data that you would like to see.



Yes, you can. Just define it as NSDictionary

and go to the metadata field. Note the custom fields below push_ups

, sit_ups

and status


let end = NSDate()
let start = NSCalendar.currentCalendar().dateByAddingUnit(.CalendarUnitMinute,
    value: -2, toDate: end, options: nil)

let energyBurned = HKQuantity(unit: HKUnit.kilocalorieUnit(),
    doubleValue: 425.0)

let distance = HKQuantity(unit: HKUnit.mileUnit(),
    doubleValue: 0)

let status = "felt okay...could have done more"
let push_ups = 40
let sit_ups = 50

let s = ["push_ups": push_ups,
    "sit_ups": sit_ups,
    "notes": status
    ] as NSDictionary

// Provide summary information when creating the workout.
let wrkOut = HKWorkout(activityType: HKWorkoutActivityType.FunctionalStrengthTraining,
    startDate: start, endDate: end, duration: 0,
    totalEnergyBurned: energyBurned, totalDistance: distance, metadata: s as! [NSObject : AnyObject])




All Articles