iOS10 Mindful Minutes - How to write?

In iOS10 beta the 'Mindful Minutes' (under Mindfulness in Health App) seem like they should be writable with HealthKit, does anyone know how? I can't seem to find any new HKActivityType or something similar to do it. Any iOS10 HealthKit information about this would be appreciated. Thanks very much!

I'm also curious. I thought entering a workout of type mindAndBody might register these minutes, but looks like that's not the case.

Accepted Answer

Ahh, I found it. It's a new HKCategoryType:


Request authorization for:


        let hkTypesToRead = Set([HKObjectType.categoryType(forIdentifier: .mindfulSession)!])
        let hkTypesToWrite = Set([HKSampleType.categoryType(forIdentifier: .mindfulSession)!])


Write minutes:


    func saveMeditation(startDate:Date, minutes:UInt) {
        let mindfulType = HKCategoryType.categoryType(forIdentifier: .mindfulSession)
        let mindfulSample = HKCategorySample(type: mindfulType!, value: 0, start: Date.init(timeIntervalSinceNow: -(15*60)), end: Date())
        healthKitStore.save(mindfulSample) { success, error in
            if(error != nil) {
                abort()
            }
        }
    }
iOS10 Mindful Minutes - How to write?
 
 
Q