SlideShare une entreprise Scribd logo
1  sur  17
Télécharger pour lire hors ligne
HealthKit
Busra Deniz
SWE-551, Fall 2015
HealthKit Overview
● HealthKit allows apps that provide health and fitness
services to share their data with the new Health app
and with each other.
● A user’s health information is stored in a centralized
and secure location and the user decides which data
should be shared with your app
● HealthKit is designed to manage data from a wide
range of sources, automatically merging data from all
different sources based on users’ preferences.
● Works with directly health and fitness devices.
HealthKit Overview
● Provides an app to help manage
users’ health data.
● View, add, delete and manage health
and fitness data using this app
● Edit sharing permissions for each
data type
● Both HealthKit and Health app are
unavailable on iPad
● The HealthKit framework cannot be
used in an app extension
HealthKit and Privacy
● The user must explicitly grant each app permission to read and write data
to HealthKit store. Users can grant or deny permission separately for each
type of data
● The HealthKit data is only kept locally on the user’s device
● For security, the HealthKit store is encrypted when the device is not
unlocked
● The HealthKit store can only be accessed by an
authorized app. Not accessible from extensions or a
WatchKit app
● Your app must not access the HealthKit APIs unless
the app is primarily designed to provide health or
fitness services
HealthKit Benefits
● Separating data collection, data processing, and
socialization
● Reduces friction in sharing between apps
● Providing a richer set of data and a greater sense of
context
● Lets apps participate in a greater ecosystem
HealthKit’s Design Philosophy
● The framework constrains the types of data and units to a predefined
list. Developers cannot create custom data types or units
● All objects in the HealthKit store are subclasses of the HKObject class
○ UUID
○ Source
○ Metadata
● HealthKit objects can be divided into two main groups :
○ Characteristics
○ Samples
HealthKit’s Design Philosophy
● Characteristic objects represent data that typically does not change. This
data includes the user’s birthdate, blood type, and biological sex
● Sample objects represent data at a particular point in time. Subclasses of
HKSample class
○ Type
○ Start date
○ End date
● Samples can be further partitioned into four sample types :
○ Category samples
○ Quantity samples
○ Correlations
○ Workouts
Setting Up HealthKit
Setting Up HealthKit
● Check to see whether HealthKit is available by calling the
isHealthDataAvailable method
● Instantiate an HKHealthStore object for your app. You need only one
HealthKit store per app.
● Request authorization to access HealthKit data using the
requestAuthorizationToShareTypes:readTypes:completion: method.
HealthKit requires fine-grained authorization. You must request
permission to share and read each type of data.
Sample Code
import HealthKit
let healthKitStore:HKHealthStore = HKHealthStore()
func authorizeHealthKit(completion: ((success:Bool, error:NSError!) -> Void)!)
{
// 1. Set the types you want to read from HK Store
let healthKitTypesToRead = Set(arrayLiteral:[
HKObjectType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierDateOfBirth),
HKObjectType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierBloodType),
HKObjectType.workoutType()
])
// 2. Set the types you want to write to HK Store
let healthKitTypesToWrite = Set(arrayLiteral:[
HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned),
HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDistanceWalkingRunning),
HKQuantityType.workoutType()
])
// Continue
Sample Code Continue
// 3. If the store is not available (for instance, iPad) return an error and don't go on.
if !HKHealthStore.isHealthDataAvailable()
{
let error = NSError(domain: "com.example.healthkit", code: 2, userInfo: [NSLocalizedDescriptionKey:"
HealthKit is not available in this Device"])
if( completion != nil )
{
completion(success:false, error:error)
}
return;
}
// 4. Request HealthKit authorization
healthKitStore.requestAuthorizationToShareTypes(healthKitTypesToWrite, readTypes: healthKitTypesToRead)
{ (success, error) -> Void in
if( completion != nil )
{
completion(success:success,error:error)
}
}
}
Sample Code Continue
healthManager.authorizeHealthKit { (authorized, error) -> Void in
if authorized {
println("HealthKit authorization received.")
} else {
println("HealthKit authorization denied!")
if error != nil {
println("(error)")
}
}
}
Read Characteristics
func readCharacteristics() -> ( biologicalsex:HKBiologicalSexObject?, bloodtype:HKBloodTypeObject?) {
var error:NSError?
// Read biological sex
var biologicalSex:HKBiologicalSexObject? = healthKitStore.biologicalSexWithError(&error);
if error != nil {
println("Error reading Biological Sex: (error)")
}
// Read blood type
var bloodType:HKBloodTypeObject? = healthKitStore.bloodTypeWithError(&error);
if error != nil {
println("Error reading Blood Type: (error)")
}
// Return the information
return (biologicalSex, bloodType)
}
Samples Query
func readMostRecentSample(sampleType:HKSampleType , completion: ((HKSample!, NSError!) -> Void)!)
{
// 1. Build the Predicate
let past = NSDate.distantPast() as! NSDate
let now = NSDate()
let mostRecentPredicate = HKQuery.predicateForSamplesWithStartDate(past, endDate:now, options: .None)
// 2. Build the sort descriptor to return the samples in descending order
let sortDescriptor = NSSortDescriptor(key:HKSampleSortIdentifierStartDate, ascending: false)
// 3. we want to limit the number of samples returned by the query to just 1 (the most recent)
let limit = 1
// 4. Build samples query
let sampleQuery = HKSampleQuery(sampleType: sampleType, predicate: mostRecentPredicate, limit: limit, sortDescriptors: [sortDescriptor])
{ (sampleQuery, results, error ) -> Void in
if let queryError = error {
completion(nil,error)
return;
}
// Get the first sample
let mostRecentSample = results.first as? HKQuantitySample
// Execute the completion closure
if completion != nil {
completion(mostRecentSample,nil)
}
}
// 5. Execute the Query
self.healthKitStore.executeQuery(sampleQuery)
}
Save New Samples
func saveBMISample(bmi:Double, date:NSDate ) {
// 1. Create a BMI Sample
let bmiType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMassIndex)
let bmiQuantity = HKQuantity(unit: HKUnit.countUnit(), doubleValue: bmi)
let bmiSample = HKQuantitySample(type: bmiType, quantity: bmiQuantity, startDate: date, endDate: date)
// 2. Save the sample in the store
healthKitStore.saveObject(bmiSample, withCompletion: { (success, error) -> Void in
if( error != nil ) {
println("Error saving BMI sample: (error.localizedDescription)")
} else {
println("BMI sample saved successfully!")
}
})
}
Classes
https://developer.apple.
com/library/ios/documentation/HealthKit/Reference/HealthKit_Framework/
References
● https://developer.apple.
com/library/ios/documentation/HealthKit/Reference/HealthKit_Framewor
k/
● http://www.raywenderlich.com/86336/ios-8-healthkit-swift-getting-started
● http://code.tutsplus.com/tutorials/getting-started-with-healthkit-part-1--
cms-24477
● http://www.raywenderlich.com/89733/healthkit-tutorial-with-swift-
workouts

Contenu connexe

Tendances

Web ,app and db server presentation
Web ,app and db server presentationWeb ,app and db server presentation
Web ,app and db server presentationParth Godhani
 
Cloud computing assignment
Cloud computing assignmentCloud computing assignment
Cloud computing assignmentACCA Global
 
Literature Review: Security on cloud computing
Literature Review: Security on cloud computingLiterature Review: Security on cloud computing
Literature Review: Security on cloud computingSuranga Nisiwasala
 
Introduction to IoT Security
Introduction to IoT SecurityIntroduction to IoT Security
Introduction to IoT SecurityCAS
 
Getting Started in Pentesting the Cloud: Azure
Getting Started in Pentesting the Cloud: AzureGetting Started in Pentesting the Cloud: Azure
Getting Started in Pentesting the Cloud: AzureBeau Bullock
 
Threat Modeling web applications (2012 update)
Threat Modeling web applications (2012 update)Threat Modeling web applications (2012 update)
Threat Modeling web applications (2012 update)Antonio Fontes
 
Security Requirements in IoT Architecture
Security	Requirements	in	IoT	Architecture Security	Requirements	in	IoT	Architecture
Security Requirements in IoT Architecture Vrince Vimal
 
Introduction to Cyber Security
Introduction to Cyber SecurityIntroduction to Cyber Security
Introduction to Cyber SecurityPriyanshu Ratnakar
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesSam Bowne
 
Cloud Computing Security
Cloud Computing SecurityCloud Computing Security
Cloud Computing SecurityNinh Nguyen
 
Step by Step Installation of Microsoft SQL Server 2012
Step by Step Installation of Microsoft SQL Server 2012 Step by Step Installation of Microsoft SQL Server 2012
Step by Step Installation of Microsoft SQL Server 2012 Sameh AboulDahab
 
IOT and Characteristics of IOT
IOT and  Characteristics of IOTIOT and  Characteristics of IOT
IOT and Characteristics of IOTAmberSinghal1
 
Mobile Cloud Comuting
Mobile Cloud Comuting Mobile Cloud Comuting
Mobile Cloud Comuting ines beltaief
 
Growing cyber crime
Growing cyber crimeGrowing cyber crime
Growing cyber crimeAman Kumar
 
what is bitcoin, its history and detail
what is bitcoin, its history and detailwhat is bitcoin, its history and detail
what is bitcoin, its history and detailSelf-employed
 

Tendances (20)

Web ,app and db server presentation
Web ,app and db server presentationWeb ,app and db server presentation
Web ,app and db server presentation
 
Cloud computing assignment
Cloud computing assignmentCloud computing assignment
Cloud computing assignment
 
Cyber Security
Cyber SecurityCyber Security
Cyber Security
 
Blockchain with iot
Blockchain with iotBlockchain with iot
Blockchain with iot
 
Literature Review: Security on cloud computing
Literature Review: Security on cloud computingLiterature Review: Security on cloud computing
Literature Review: Security on cloud computing
 
Introduction to IoT Security
Introduction to IoT SecurityIntroduction to IoT Security
Introduction to IoT Security
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
Getting Started in Pentesting the Cloud: Azure
Getting Started in Pentesting the Cloud: AzureGetting Started in Pentesting the Cloud: Azure
Getting Started in Pentesting the Cloud: Azure
 
Malware
MalwareMalware
Malware
 
Threat Modeling web applications (2012 update)
Threat Modeling web applications (2012 update)Threat Modeling web applications (2012 update)
Threat Modeling web applications (2012 update)
 
Introduction to Blockchain
Introduction to BlockchainIntroduction to Blockchain
Introduction to Blockchain
 
Security Requirements in IoT Architecture
Security	Requirements	in	IoT	Architecture Security	Requirements	in	IoT	Architecture
Security Requirements in IoT Architecture
 
Introduction to Cyber Security
Introduction to Cyber SecurityIntroduction to Cyber Security
Introduction to Cyber Security
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application Technologies
 
Cloud Computing Security
Cloud Computing SecurityCloud Computing Security
Cloud Computing Security
 
Step by Step Installation of Microsoft SQL Server 2012
Step by Step Installation of Microsoft SQL Server 2012 Step by Step Installation of Microsoft SQL Server 2012
Step by Step Installation of Microsoft SQL Server 2012
 
IOT and Characteristics of IOT
IOT and  Characteristics of IOTIOT and  Characteristics of IOT
IOT and Characteristics of IOT
 
Mobile Cloud Comuting
Mobile Cloud Comuting Mobile Cloud Comuting
Mobile Cloud Comuting
 
Growing cyber crime
Growing cyber crimeGrowing cyber crime
Growing cyber crime
 
what is bitcoin, its history and detail
what is bitcoin, its history and detailwhat is bitcoin, its history and detail
what is bitcoin, its history and detail
 

En vedette

SDP (Session Description Protocol)
SDP (Session Description Protocol)SDP (Session Description Protocol)
SDP (Session Description Protocol)Buşra Deniz, CSM
 
Apple Health Kit from the Application Developer Point of View
Apple Health Kit from the Application Developer Point of ViewApple Health Kit from the Application Developer Point of View
Apple Health Kit from the Application Developer Point of ViewGene Leybzon
 
How to Connect with HealthKit App with NewU
How to Connect with HealthKit App with NewUHow to Connect with HealthKit App with NewU
How to Connect with HealthKit App with NewUAbhinav Singh
 
Ergonomics - For Employees Satisfaction
Ergonomics - For Employees SatisfactionErgonomics - For Employees Satisfaction
Ergonomics - For Employees Satisfactioncomplement-ltd
 
Business Sectors & Its contribution in india
Business Sectors & Its contribution in indiaBusiness Sectors & Its contribution in india
Business Sectors & Its contribution in indiaRaushan Pandey
 
10 seconds Rule on 5 jan.
10 seconds Rule on 5 jan.10 seconds Rule on 5 jan.
10 seconds Rule on 5 jan.Gettowork
 
Egg shell color
Egg shell colorEgg shell color
Egg shell colorMohsen Ali
 
Tarlan kajian benthic terrain ruggedness
Tarlan kajian benthic terrain ruggednessTarlan kajian benthic terrain ruggedness
Tarlan kajian benthic terrain ruggednessallan_awani
 
Triple moinitor wall mount
Triple moinitor wall mountTriple moinitor wall mount
Triple moinitor wall mountcomplement-ltd
 
Tutorial penginstalan joomla cms 2
Tutorial penginstalan joomla cms 2Tutorial penginstalan joomla cms 2
Tutorial penginstalan joomla cms 2150399
 

En vedette (18)

SDP (Session Description Protocol)
SDP (Session Description Protocol)SDP (Session Description Protocol)
SDP (Session Description Protocol)
 
Apple Health Kit from the Application Developer Point of View
Apple Health Kit from the Application Developer Point of ViewApple Health Kit from the Application Developer Point of View
Apple Health Kit from the Application Developer Point of View
 
How to Connect with HealthKit App with NewU
How to Connect with HealthKit App with NewUHow to Connect with HealthKit App with NewU
How to Connect with HealthKit App with NewU
 
ชุดที่ 3
ชุดที่ 3ชุดที่ 3
ชุดที่ 3
 
work4-57
work4-57work4-57
work4-57
 
work3-56
work3-56work3-56
work3-56
 
onet-work4-56
onet-work4-56onet-work4-56
onet-work4-56
 
Ergonomics - For Employees Satisfaction
Ergonomics - For Employees SatisfactionErgonomics - For Employees Satisfaction
Ergonomics - For Employees Satisfaction
 
Business Sectors & Its contribution in india
Business Sectors & Its contribution in indiaBusiness Sectors & Its contribution in india
Business Sectors & Its contribution in india
 
10 seconds Rule on 5 jan.
10 seconds Rule on 5 jan.10 seconds Rule on 5 jan.
10 seconds Rule on 5 jan.
 
Egg shell color
Egg shell colorEgg shell color
Egg shell color
 
Tarlan kajian benthic terrain ruggedness
Tarlan kajian benthic terrain ruggednessTarlan kajian benthic terrain ruggedness
Tarlan kajian benthic terrain ruggedness
 
ชุดที่ 2
ชุดที่ 2ชุดที่ 2
ชุดที่ 2
 
Triple moinitor wall mount
Triple moinitor wall mountTriple moinitor wall mount
Triple moinitor wall mount
 
Tutorial penginstalan joomla cms 2
Tutorial penginstalan joomla cms 2Tutorial penginstalan joomla cms 2
Tutorial penginstalan joomla cms 2
 
ชุดที่ 1
ชุดที่ 1ชุดที่ 1
ชุดที่ 1
 
work3-57
work3-57work3-57
work3-57
 
Unit testing on mobile apps
Unit testing on mobile appsUnit testing on mobile apps
Unit testing on mobile apps
 

Similaire à HealthKit

Health and fitness frameworks
Health and fitness frameworksHealth and fitness frameworks
Health and fitness frameworksDiversido
 
Health vault intro for developers
Health vault intro for developersHealth vault intro for developers
Health vault intro for developersaliemami
 
Presentation 2 - FHIR Overview
Presentation 2 - FHIR OverviewPresentation 2 - FHIR Overview
Presentation 2 - FHIR OverviewTom Wilson
 
Final application
Final applicationFinal application
Final applicationtomcook8
 
Demystifying SPL for Medical Devices
Demystifying SPL for Medical DevicesDemystifying SPL for Medical Devices
Demystifying SPL for Medical Devicesdclsocialmedia
 
Concept: Consumer Centric IoT Healthcare Exchange
Concept:  Consumer Centric IoT Healthcare ExchangeConcept:  Consumer Centric IoT Healthcare Exchange
Concept: Consumer Centric IoT Healthcare ExchangeJason de la Fuente
 
The need for interoperability in blockchain-based initiatives to facilitate c...
The need for interoperability in blockchain-based initiatives to facilitate c...The need for interoperability in blockchain-based initiatives to facilitate c...
The need for interoperability in blockchain-based initiatives to facilitate c...Massimiliano Masi
 
E health registration next steps
E health registration next stepsE health registration next steps
E health registration next stepsleapfrogsolutions
 
Hosiptal-MS-PPT-zl64ci.pptx
Hosiptal-MS-PPT-zl64ci.pptxHosiptal-MS-PPT-zl64ci.pptx
Hosiptal-MS-PPT-zl64ci.pptxrohanthombre2
 
Web 2.0 In Healthcare
Web 2.0 In HealthcareWeb 2.0 In Healthcare
Web 2.0 In HealthcareAnne Madden
 

Similaire à HealthKit (15)

Health and fitness frameworks
Health and fitness frameworksHealth and fitness frameworks
Health and fitness frameworks
 
Health vault intro for developers
Health vault intro for developersHealth vault intro for developers
Health vault intro for developers
 
Apple Health Kit
Apple Health KitApple Health Kit
Apple Health Kit
 
Hsc 2008 Day 2
Hsc 2008   Day 2Hsc 2008   Day 2
Hsc 2008 Day 2
 
Presentation 2 - FHIR Overview
Presentation 2 - FHIR OverviewPresentation 2 - FHIR Overview
Presentation 2 - FHIR Overview
 
2012 User's Conference Indivo Updates
2012 User's Conference Indivo Updates2012 User's Conference Indivo Updates
2012 User's Conference Indivo Updates
 
Final application
Final applicationFinal application
Final application
 
Demystifying SPL for Medical Devices
Demystifying SPL for Medical DevicesDemystifying SPL for Medical Devices
Demystifying SPL for Medical Devices
 
Original
OriginalOriginal
Original
 
Concept: Consumer Centric IoT Healthcare Exchange
Concept:  Consumer Centric IoT Healthcare ExchangeConcept:  Consumer Centric IoT Healthcare Exchange
Concept: Consumer Centric IoT Healthcare Exchange
 
The need for interoperability in blockchain-based initiatives to facilitate c...
The need for interoperability in blockchain-based initiatives to facilitate c...The need for interoperability in blockchain-based initiatives to facilitate c...
The need for interoperability in blockchain-based initiatives to facilitate c...
 
E health registration next steps
E health registration next stepsE health registration next steps
E health registration next steps
 
Hosiptal-MS-PPT-zl64ci.pptx
Hosiptal-MS-PPT-zl64ci.pptxHosiptal-MS-PPT-zl64ci.pptx
Hosiptal-MS-PPT-zl64ci.pptx
 
Biothings presentation
Biothings presentationBiothings presentation
Biothings presentation
 
Web 2.0 In Healthcare
Web 2.0 In HealthcareWeb 2.0 In Healthcare
Web 2.0 In Healthcare
 

Dernier

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 

Dernier (20)

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 

HealthKit

  • 2. HealthKit Overview ● HealthKit allows apps that provide health and fitness services to share their data with the new Health app and with each other. ● A user’s health information is stored in a centralized and secure location and the user decides which data should be shared with your app ● HealthKit is designed to manage data from a wide range of sources, automatically merging data from all different sources based on users’ preferences. ● Works with directly health and fitness devices.
  • 3. HealthKit Overview ● Provides an app to help manage users’ health data. ● View, add, delete and manage health and fitness data using this app ● Edit sharing permissions for each data type ● Both HealthKit and Health app are unavailable on iPad ● The HealthKit framework cannot be used in an app extension
  • 4. HealthKit and Privacy ● The user must explicitly grant each app permission to read and write data to HealthKit store. Users can grant or deny permission separately for each type of data ● The HealthKit data is only kept locally on the user’s device ● For security, the HealthKit store is encrypted when the device is not unlocked ● The HealthKit store can only be accessed by an authorized app. Not accessible from extensions or a WatchKit app ● Your app must not access the HealthKit APIs unless the app is primarily designed to provide health or fitness services
  • 5. HealthKit Benefits ● Separating data collection, data processing, and socialization ● Reduces friction in sharing between apps ● Providing a richer set of data and a greater sense of context ● Lets apps participate in a greater ecosystem
  • 6. HealthKit’s Design Philosophy ● The framework constrains the types of data and units to a predefined list. Developers cannot create custom data types or units ● All objects in the HealthKit store are subclasses of the HKObject class ○ UUID ○ Source ○ Metadata ● HealthKit objects can be divided into two main groups : ○ Characteristics ○ Samples
  • 7. HealthKit’s Design Philosophy ● Characteristic objects represent data that typically does not change. This data includes the user’s birthdate, blood type, and biological sex ● Sample objects represent data at a particular point in time. Subclasses of HKSample class ○ Type ○ Start date ○ End date ● Samples can be further partitioned into four sample types : ○ Category samples ○ Quantity samples ○ Correlations ○ Workouts
  • 9. Setting Up HealthKit ● Check to see whether HealthKit is available by calling the isHealthDataAvailable method ● Instantiate an HKHealthStore object for your app. You need only one HealthKit store per app. ● Request authorization to access HealthKit data using the requestAuthorizationToShareTypes:readTypes:completion: method. HealthKit requires fine-grained authorization. You must request permission to share and read each type of data.
  • 10. Sample Code import HealthKit let healthKitStore:HKHealthStore = HKHealthStore() func authorizeHealthKit(completion: ((success:Bool, error:NSError!) -> Void)!) { // 1. Set the types you want to read from HK Store let healthKitTypesToRead = Set(arrayLiteral:[ HKObjectType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierDateOfBirth), HKObjectType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierBloodType), HKObjectType.workoutType() ]) // 2. Set the types you want to write to HK Store let healthKitTypesToWrite = Set(arrayLiteral:[ HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned), HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDistanceWalkingRunning), HKQuantityType.workoutType() ]) // Continue
  • 11. Sample Code Continue // 3. If the store is not available (for instance, iPad) return an error and don't go on. if !HKHealthStore.isHealthDataAvailable() { let error = NSError(domain: "com.example.healthkit", code: 2, userInfo: [NSLocalizedDescriptionKey:" HealthKit is not available in this Device"]) if( completion != nil ) { completion(success:false, error:error) } return; } // 4. Request HealthKit authorization healthKitStore.requestAuthorizationToShareTypes(healthKitTypesToWrite, readTypes: healthKitTypesToRead) { (success, error) -> Void in if( completion != nil ) { completion(success:success,error:error) } } }
  • 12. Sample Code Continue healthManager.authorizeHealthKit { (authorized, error) -> Void in if authorized { println("HealthKit authorization received.") } else { println("HealthKit authorization denied!") if error != nil { println("(error)") } } }
  • 13. Read Characteristics func readCharacteristics() -> ( biologicalsex:HKBiologicalSexObject?, bloodtype:HKBloodTypeObject?) { var error:NSError? // Read biological sex var biologicalSex:HKBiologicalSexObject? = healthKitStore.biologicalSexWithError(&error); if error != nil { println("Error reading Biological Sex: (error)") } // Read blood type var bloodType:HKBloodTypeObject? = healthKitStore.bloodTypeWithError(&error); if error != nil { println("Error reading Blood Type: (error)") } // Return the information return (biologicalSex, bloodType) }
  • 14. Samples Query func readMostRecentSample(sampleType:HKSampleType , completion: ((HKSample!, NSError!) -> Void)!) { // 1. Build the Predicate let past = NSDate.distantPast() as! NSDate let now = NSDate() let mostRecentPredicate = HKQuery.predicateForSamplesWithStartDate(past, endDate:now, options: .None) // 2. Build the sort descriptor to return the samples in descending order let sortDescriptor = NSSortDescriptor(key:HKSampleSortIdentifierStartDate, ascending: false) // 3. we want to limit the number of samples returned by the query to just 1 (the most recent) let limit = 1 // 4. Build samples query let sampleQuery = HKSampleQuery(sampleType: sampleType, predicate: mostRecentPredicate, limit: limit, sortDescriptors: [sortDescriptor]) { (sampleQuery, results, error ) -> Void in if let queryError = error { completion(nil,error) return; } // Get the first sample let mostRecentSample = results.first as? HKQuantitySample // Execute the completion closure if completion != nil { completion(mostRecentSample,nil) } } // 5. Execute the Query self.healthKitStore.executeQuery(sampleQuery) }
  • 15. Save New Samples func saveBMISample(bmi:Double, date:NSDate ) { // 1. Create a BMI Sample let bmiType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMassIndex) let bmiQuantity = HKQuantity(unit: HKUnit.countUnit(), doubleValue: bmi) let bmiSample = HKQuantitySample(type: bmiType, quantity: bmiQuantity, startDate: date, endDate: date) // 2. Save the sample in the store healthKitStore.saveObject(bmiSample, withCompletion: { (success, error) -> Void in if( error != nil ) { println("Error saving BMI sample: (error.localizedDescription)") } else { println("BMI sample saved successfully!") } }) }
  • 17. References ● https://developer.apple. com/library/ios/documentation/HealthKit/Reference/HealthKit_Framewor k/ ● http://www.raywenderlich.com/86336/ios-8-healthkit-swift-getting-started ● http://code.tutsplus.com/tutorials/getting-started-with-healthkit-part-1-- cms-24477 ● http://www.raywenderlich.com/89733/healthkit-tutorial-with-swift- workouts