SlideShare a Scribd company logo
1 of 26
Download to read offline
INTRODUCING CARDIOMERCARI INC.
@KITASUKE
ABOUT ME
MY FUTURE TALKS
> Search APIs and Universal Links in practice
@iOS9 bootcamp
> Introducing new features for watchOS 2
@MOSA software meeting
HEALTHKIT
HealthKit allows apps that provide health
and fitness services
— HealthKit Framework Reference
CLASSES
> HKDevice
> HKSample
> HKObjectType
> HKQuantity
> HKUnit
> HKQuery
HKQUERY
> HKSampleQuery
> HKObserverQuery
> HKAnchoredObjectQuery
> HKStatisticsQuery
> HKStatisticsCollectionQuery
> HKCorrelation
> HKSourceQuery
HEART RATE IN WATCHOS-2-SAMPLER
class HeartRateInterfaceController: WKInterfaceController {
let healthStore = HKHealthStore()
let heartRateType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeartRate)!
let heartRateUnit = HKUnit(fromString: "count/min")
var heartRateQuery: HKQuery?
override func willActivate() {
super.willActivate()
guard HKHealthStore.isHealthDataAvailable() else { return }
let dataTypes = Set([heartRateType])
healthStore.requestAuthorizationToShareTypes(nil, readTypes: dataTypes) { (success, error) -> Void in
guard success else { return }
}
}
@IBAction func fetchBtnTapped() {
guard self.heartRateQuery == nil else { return }
if self.heartRateQuery == nil {
self.heartRateQuery = self.createStreamingQuery()
self.healthStore.executeQuery(self.heartRateQuery!)
} else {
self.healthStore.stopQuery(self.heartRateQuery!)
self.heartRateQuery = nil
}
}
private func createStreamingQuery() -> HKQuery {
let predicate = HKQuery.predicateForSamplesWithStartDate(NSDate(), endDate: nil, options: .None)
let query = HKAnchoredObjectQuery(type: heartRateType, predicate: predicate, anchor: nil, limit: Int(HKObjectQueryNoLimit)) { (query, samples, deletedObjects, anchor, error) -> Void in
self.addSamples(samples)
}
query.updateHandler = { (query, samples, deletedObjects, anchor, error) -> Void in
self.addSamples(samples)
}
return query
}
private func addSamples(samples: [HKSample]?) {
guard let samples = samples as? [HKQuantitySample] else { return }
guard let quantity = samples.last?.quantity else { return }
let heartRate = quantity.doubleValueForUnit(heartRateUnit)
}
}
!
CARDIO!HTTPS://GITHUB.COM/KITASUKE/CARDIO
HEALTHKIT WRAPPER
SPECIALIZED FOR
WORKOUT
FEATURES
> Super simple to access HealthKit
> Cuztomizable preferences
> Well-designed for workout app
> Easy way to save workout data in HealthKit
REQUIREMENTS
> watchOS 2.0+
> Swift 2.0+
INSTALLATION
Carthage
github "kitasuke/Cardio"
Add HealthKit entitlements into both containing
iOS app target and WatchKit Extension target
CONTEXT PROTOCOL
public protocol Context {
var activityType: HKWorkoutActivityType { get }
var locationType: HKWorkoutSessionLocationType { get }
var distanceUnit: HKUnit { get }
var activeEnergyUnit: HKUnit { get }
var heartRateUnit: HKUnit { get }
var distanceType: HKQuantityType { get }
var activeEnergyType: HKQuantityType { get }
var heartRateType: HKQuantityType { get }
var shareIdentifiers: [String] { get }
var readIdentifiers: [String] { get }
}
CONTEXT EXTENSION
public extension Context {
public var activityType: HKWorkoutActivityType {
return .Running
}
public var locationType: HKWorkoutSessionLocationType {
return .Outdoor
}
public var distanceUnit: HKUnit {
return HKUnit.meterUnitWithMetricPrefix(.Kilo)
}
public var activeEnergyUnit: HKUnit {
return HKUnit.kilocalorieUnit()
}
public var heartRateUnit: HKUnit {
return HKUnit(fromString: "count/min")
}
...
}
STRUCT CONFORMED CONTEXT
struct CardioContext: Context {
var locationType: HKWorkoutSessionLocationType {
return .Indoor
}
var distanceUnit: HKUnit {
return HKUnit.mileUnit()
}
var shareIdentifiers: [String] {
return []
}
}
INITIALIZATION
let context = CardioContext()
cardio = Cardio(context: context)
AUTHORIZATION
WATCHKIT EXTENSION TARGET
cardio.authorize { result in
}
CONTAINING IOS APP TARGET
func applicationShouldRequestHealthAuthorization(application: UIApplication) {
authorize()
}
UPDATE HANDLERS
cardio.distanceHandler = { distance, total in
}
cardio.activeEnergyHandler = { activeEnergy, total in
}
cardio.heartRateHandler = { heartRate, average in
}
WORKOUT SESSION
cardio.start { result in
}
cardio.end { result in
}
SAVE WORKOUT DATA
cardio.save() { result in
}
FUTURE WORK
> Add more features
> Fully support HealthKit
> Make wrapper for iOS app target
WELCOME YOUR
FEEDBACK &
THOUGHTS !
ANY QUESTIONS?

More Related Content

What's hot

Introduction to SharePoint 2013 REST API
Introduction to SharePoint 2013 REST APIIntroduction to SharePoint 2013 REST API
Introduction to SharePoint 2013 REST APIQUONTRASOLUTIONS
 
Android Intermediatte IAK full
Android Intermediatte IAK fullAndroid Intermediatte IAK full
Android Intermediatte IAK fullAhmad Arif Faizin
 
Building Android apps with Parse
Building Android apps with ParseBuilding Android apps with Parse
Building Android apps with ParseDroidConTLV
 
AnDevCon - Tracking User Behavior Creatively
AnDevCon - Tracking User Behavior CreativelyAnDevCon - Tracking User Behavior Creatively
AnDevCon - Tracking User Behavior CreativelyKiana Tennyson
 
Deep Dive into the ArcGIS Geotrigger Service - Esri DevSummit Dubai 2013
Deep Dive into the ArcGIS Geotrigger Service - Esri DevSummit Dubai 2013Deep Dive into the ArcGIS Geotrigger Service - Esri DevSummit Dubai 2013
Deep Dive into the ArcGIS Geotrigger Service - Esri DevSummit Dubai 2013Aaron Parecki
 
File Repository on GAE
File Repository on GAEFile Repository on GAE
File Repository on GAElynneblue
 
I Love APIs 2015: Apache Usergrid Web Scale Mobile APIs with Elastic Search a...
I Love APIs 2015: Apache Usergrid Web Scale Mobile APIs with Elastic Search a...I Love APIs 2015: Apache Usergrid Web Scale Mobile APIs with Elastic Search a...
I Love APIs 2015: Apache Usergrid Web Scale Mobile APIs with Elastic Search a...Apigee | Google Cloud
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android JetpackAhmad Arif Faizin
 
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...Lviv Startup Club
 
SharePoint Saturday Baltimore 7/25/09 - Introduction To Developing Custom Act...
SharePoint Saturday Baltimore 7/25/09 - Introduction To Developing Custom Act...SharePoint Saturday Baltimore 7/25/09 - Introduction To Developing Custom Act...
SharePoint Saturday Baltimore 7/25/09 - Introduction To Developing Custom Act...Geoff Varosky
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code維佋 唐
 
Sharepoint Saturday India Online best practice for developing share point sol...
Sharepoint Saturday India Online best practice for developing share point sol...Sharepoint Saturday India Online best practice for developing share point sol...
Sharepoint Saturday India Online best practice for developing share point sol...Shakir Majeed Khan
 
Cloud native programming model comparison
Cloud native programming model comparisonCloud native programming model comparison
Cloud native programming model comparisonEmily Jiang
 

What's hot (19)

Introduction to SharePoint 2013 REST API
Introduction to SharePoint 2013 REST APIIntroduction to SharePoint 2013 REST API
Introduction to SharePoint 2013 REST API
 
Node.js and Parse
Node.js and ParseNode.js and Parse
Node.js and Parse
 
Android Intermediatte IAK full
Android Intermediatte IAK fullAndroid Intermediatte IAK full
Android Intermediatte IAK full
 
Building Android apps with Parse
Building Android apps with ParseBuilding Android apps with Parse
Building Android apps with Parse
 
AnDevCon - Tracking User Behavior Creatively
AnDevCon - Tracking User Behavior CreativelyAnDevCon - Tracking User Behavior Creatively
AnDevCon - Tracking User Behavior Creatively
 
Deep Dive into the ArcGIS Geotrigger Service - Esri DevSummit Dubai 2013
Deep Dive into the ArcGIS Geotrigger Service - Esri DevSummit Dubai 2013Deep Dive into the ArcGIS Geotrigger Service - Esri DevSummit Dubai 2013
Deep Dive into the ArcGIS Geotrigger Service - Esri DevSummit Dubai 2013
 
Search API
Search APISearch API
Search API
 
File Repository on GAE
File Repository on GAEFile Repository on GAE
File Repository on GAE
 
Actionview
ActionviewActionview
Actionview
 
I Love APIs 2015: Apache Usergrid Web Scale Mobile APIs with Elastic Search a...
I Love APIs 2015: Apache Usergrid Web Scale Mobile APIs with Elastic Search a...I Love APIs 2015: Apache Usergrid Web Scale Mobile APIs with Elastic Search a...
I Love APIs 2015: Apache Usergrid Web Scale Mobile APIs with Elastic Search a...
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android Jetpack
 
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
 
Parse Advanced
Parse AdvancedParse Advanced
Parse Advanced
 
SharePoint Saturday Baltimore 7/25/09 - Introduction To Developing Custom Act...
SharePoint Saturday Baltimore 7/25/09 - Introduction To Developing Custom Act...SharePoint Saturday Baltimore 7/25/09 - Introduction To Developing Custom Act...
SharePoint Saturday Baltimore 7/25/09 - Introduction To Developing Custom Act...
 
Android Froyo
Android FroyoAndroid Froyo
Android Froyo
 
Amazon Rekognition Workshop
Amazon Rekognition WorkshopAmazon Rekognition Workshop
Amazon Rekognition Workshop
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
Sharepoint Saturday India Online best practice for developing share point sol...
Sharepoint Saturday India Online best practice for developing share point sol...Sharepoint Saturday India Online best practice for developing share point sol...
Sharepoint Saturday India Online best practice for developing share point sol...
 
Cloud native programming model comparison
Cloud native programming model comparisonCloud native programming model comparison
Cloud native programming model comparison
 

Viewers also liked

Tips for better CI on Android
Tips for better CI on AndroidTips for better CI on Android
Tips for better CI on AndroidTomoaki Imai
 
Type Safe Assets Handling in Swift
Type Safe Assets Handling in SwiftType Safe Assets Handling in Swift
Type Safe Assets Handling in SwiftKazunobu Tasaka
 
My first tvOS
My first tvOSMy first tvOS
My first tvOStoyship
 
個人で開発したアプリがベスト新着に選ばれた話
個人で開発したアプリがベスト新着に選ばれた話個人で開発したアプリがベスト新着に選ばれた話
個人で開発したアプリがベスト新着に選ばれた話Motoki Narita
 
Caffeでお手軽本格ディープラーニングアプリ @potatotips
Caffeでお手軽本格ディープラーニングアプリ @potatotipsCaffeでお手軽本格ディープラーニングアプリ @potatotips
Caffeでお手軽本格ディープラーニングアプリ @potatotipsTakuya Matsuyama
 
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみるCocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみるMasayuki Nii
 
Android development at mercari 2015
Android development at mercari 2015Android development at mercari 2015
Android development at mercari 2015Tomoaki Imai
 
WatchKit@potatotips
WatchKit@potatotipsWatchKit@potatotips
WatchKit@potatotipsYusuke Kita
 
Today & Share Extension@potatotips
Today & Share Extension@potatotipsToday & Share Extension@potatotips
Today & Share Extension@potatotipsYusuke Kita
 
App extensionでテストコードを書く
App extensionでテストコードを書くApp extensionでテストコードを書く
App extensionでテストコードを書くYusuke Kita
 
Share Extension@pixiv
Share Extension@pixivShare Extension@pixiv
Share Extension@pixivYusuke Kita
 
SwiftCoreとFoundationを読んでみた
SwiftCoreとFoundationを読んでみたSwiftCoreとFoundationを読んでみた
SwiftCoreとFoundationを読んでみたYusuke Kita
 
WKInterfaceMap on Apple Watch
WKInterfaceMap on Apple WatchWKInterfaceMap on Apple Watch
WKInterfaceMap on Apple WatchYusuke Kita
 
Useful and Practical Functionalities in Realm
Useful and Practical Functionalities in RealmUseful and Practical Functionalities in Realm
Useful and Practical Functionalities in RealmYusuke Kita
 
Xcode7時代のアプリ配布
Xcode7時代のアプリ配布Xcode7時代のアプリ配布
Xcode7時代のアプリ配布toyship
 
Uiテスト@yidev
Uiテスト@yidevUiテスト@yidev
Uiテスト@yidevYusuke Kita
 

Viewers also liked (20)

Tips for better CI on Android
Tips for better CI on AndroidTips for better CI on Android
Tips for better CI on Android
 
Type Safe Assets Handling in Swift
Type Safe Assets Handling in SwiftType Safe Assets Handling in Swift
Type Safe Assets Handling in Swift
 
Objective-C Generics
Objective-C GenericsObjective-C Generics
Objective-C Generics
 
My first tvOS
My first tvOSMy first tvOS
My first tvOS
 
個人で開発したアプリがベスト新着に選ばれた話
個人で開発したアプリがベスト新着に選ばれた話個人で開発したアプリがベスト新着に選ばれた話
個人で開発したアプリがベスト新着に選ばれた話
 
Caffeでお手軽本格ディープラーニングアプリ @potatotips
Caffeでお手軽本格ディープラーニングアプリ @potatotipsCaffeでお手軽本格ディープラーニングアプリ @potatotips
Caffeでお手軽本格ディープラーニングアプリ @potatotips
 
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみるCocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
 
Android development at mercari 2015
Android development at mercari 2015Android development at mercari 2015
Android development at mercari 2015
 
WatchKit@potatotips
WatchKit@potatotipsWatchKit@potatotips
WatchKit@potatotips
 
Today & Share Extension@potatotips
Today & Share Extension@potatotipsToday & Share Extension@potatotips
Today & Share Extension@potatotips
 
App extensionでテストコードを書く
App extensionでテストコードを書くApp extensionでテストコードを書く
App extensionでテストコードを書く
 
Share Extension@pixiv
Share Extension@pixivShare Extension@pixiv
Share Extension@pixiv
 
SwiftCoreとFoundationを読んでみた
SwiftCoreとFoundationを読んでみたSwiftCoreとFoundationを読んでみた
SwiftCoreとFoundationを読んでみた
 
Swift core
Swift coreSwift core
Swift core
 
WKInterfaceMap on Apple Watch
WKInterfaceMap on Apple WatchWKInterfaceMap on Apple Watch
WKInterfaceMap on Apple Watch
 
Useful and Practical Functionalities in Realm
Useful and Practical Functionalities in RealmUseful and Practical Functionalities in Realm
Useful and Practical Functionalities in Realm
 
Swift Scriptingのすゝめ
Swift ScriptingのすゝめSwift Scriptingのすゝめ
Swift Scriptingのすゝめ
 
Xcode7時代のアプリ配布
Xcode7時代のアプリ配布Xcode7時代のアプリ配布
Xcode7時代のアプリ配布
 
View Monitoring Tips
View Monitoring TipsView Monitoring Tips
View Monitoring Tips
 
Uiテスト@yidev
Uiテスト@yidevUiテスト@yidev
Uiテスト@yidev
 

Similar to Introducing Cardio

Wearables Presentation from Queensland C# Mobile Developers August 2016
Wearables Presentation from Queensland C# Mobile Developers August 2016Wearables Presentation from Queensland C# Mobile Developers August 2016
Wearables Presentation from Queensland C# Mobile Developers August 2016Glenn Stephens
 
How to make workout app for watch os 2
How to make workout app for watch os 2How to make workout app for watch os 2
How to make workout app for watch os 2Yusuke Kita
 
Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Paco de la Cruz
 
Advanced #2 networking
Advanced #2   networkingAdvanced #2   networking
Advanced #2 networkingVitali Pekelis
 
Fiware IoT Proposal & Community
Fiware IoT Proposal & Community Fiware IoT Proposal & Community
Fiware IoT Proposal & Community TIDChile
 
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術  〜HealthKit・GCP + Goの活用〜ヘルスケアサービスを実現する最新技術  〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜DeNA
 
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術  〜HealthKit・GCP + Goの活用〜ヘルスケアサービスを実現する最新技術  〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜DeNA
 
ヘルスケアサービスを実現する最新技術
〜HealthKit・GCP+Go〜
ヘルスケアサービスを実現する最新技術
〜HealthKit・GCP+Go〜ヘルスケアサービスを実現する最新技術
〜HealthKit・GCP+Go〜
ヘルスケアサービスを実現する最新技術
〜HealthKit・GCP+Go〜Fukaya Akifumi
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design PatternsGodfrey Nolan
 
We sport architecture_implementation
We sport architecture_implementationWe sport architecture_implementation
We sport architecture_implementationaurelianaur
 
Build resource server & client for OCF Cloud (2018.8.30)
Build resource server & client for OCF Cloud (2018.8.30)Build resource server & client for OCF Cloud (2018.8.30)
Build resource server & client for OCF Cloud (2018.8.30)남균 김
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade ServerlessKatyShimizu
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade ServerlessKatyShimizu
 
Adopting 3D Touch in your apps
Adopting 3D Touch in your appsAdopting 3D Touch in your apps
Adopting 3D Touch in your appsJuan C Catalan
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web servicesnbuddharaju
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTDavid Chandler
 
Connect Intergration Patterns: A Case Study - Patrick Streule
Connect Intergration Patterns: A Case Study - Patrick StreuleConnect Intergration Patterns: A Case Study - Patrick Streule
Connect Intergration Patterns: A Case Study - Patrick StreuleAtlassian
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Andres Almiray
 

Similar to Introducing Cardio (20)

Wearables Presentation from Queensland C# Mobile Developers August 2016
Wearables Presentation from Queensland C# Mobile Developers August 2016Wearables Presentation from Queensland C# Mobile Developers August 2016
Wearables Presentation from Queensland C# Mobile Developers August 2016
 
How to make workout app for watch os 2
How to make workout app for watch os 2How to make workout app for watch os 2
How to make workout app for watch os 2
 
Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)
 
Advanced #2 networking
Advanced #2   networkingAdvanced #2   networking
Advanced #2 networking
 
Fiware IoT Proposal & Community
Fiware IoT Proposal & Community Fiware IoT Proposal & Community
Fiware IoT Proposal & Community
 
Eddystone beacons demo
Eddystone beacons demoEddystone beacons demo
Eddystone beacons demo
 
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術  〜HealthKit・GCP + Goの活用〜ヘルスケアサービスを実現する最新技術  〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
 
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術  〜HealthKit・GCP + Goの活用〜ヘルスケアサービスを実現する最新技術  〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
 
ヘルスケアサービスを実現する最新技術
〜HealthKit・GCP+Go〜
ヘルスケアサービスを実現する最新技術
〜HealthKit・GCP+Go〜ヘルスケアサービスを実現する最新技術
〜HealthKit・GCP+Go〜
ヘルスケアサービスを実現する最新技術
〜HealthKit・GCP+Go〜
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design Patterns
 
We sport architecture_implementation
We sport architecture_implementationWe sport architecture_implementation
We sport architecture_implementation
 
Build resource server & client for OCF Cloud (2018.8.30)
Build resource server & client for OCF Cloud (2018.8.30)Build resource server & client for OCF Cloud (2018.8.30)
Build resource server & client for OCF Cloud (2018.8.30)
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
 
Adopting 3D Touch in your apps
Adopting 3D Touch in your appsAdopting 3D Touch in your apps
Adopting 3D Touch in your apps
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWT
 
Connect Intergration Patterns: A Case Study - Patrick Streule
Connect Intergration Patterns: A Case Study - Patrick StreuleConnect Intergration Patterns: A Case Study - Patrick Streule
Connect Intergration Patterns: A Case Study - Patrick Streule
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
 
RxBinding-kotlin
RxBinding-kotlinRxBinding-kotlin
RxBinding-kotlin
 

More from Yusuke Kita

Integrating libSyntax into the compiler pipeline
Integrating libSyntax into the compiler pipelineIntegrating libSyntax into the compiler pipeline
Integrating libSyntax into the compiler pipelineYusuke Kita
 
Making your own tool using SwiftSyntax
Making your own tool using SwiftSyntaxMaking your own tool using SwiftSyntax
Making your own tool using SwiftSyntaxYusuke Kita
 
[Deprecated] Integrating libSyntax into the compiler pipeline
[Deprecated] Integrating libSyntax into the compiler pipeline[Deprecated] Integrating libSyntax into the compiler pipeline
[Deprecated] Integrating libSyntax into the compiler pipelineYusuke Kita
 
Creating your own Bitrise step
Creating your own Bitrise stepCreating your own Bitrise step
Creating your own Bitrise stepYusuke Kita
 
Introducing swift-format
Introducing swift-formatIntroducing swift-format
Introducing swift-formatYusuke Kita
 
Unidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUIUnidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUIYusuke Kita
 
Open Source Swift Workshop
Open Source Swift WorkshopOpen Source Swift Workshop
Open Source Swift WorkshopYusuke Kita
 
Contributing to Swift Compiler
Contributing to Swift CompilerContributing to Swift Compiler
Contributing to Swift CompilerYusuke Kita
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in goYusuke Kita
 
Writing an interpreter in swift
Writing an interpreter in swiftWriting an interpreter in swift
Writing an interpreter in swiftYusuke Kita
 
SIL Optimizations - AllocBoxToStack
SIL Optimizations - AllocBoxToStackSIL Optimizations - AllocBoxToStack
SIL Optimizations - AllocBoxToStackYusuke Kita
 
SIL for First Time Learners
SIL for First Time LearnersSIL for First Time Learners
SIL for First Time LearnersYusuke Kita
 
SIL for First Time Leaners LT
SIL for First Time Leaners LTSIL for First Time Leaners LT
SIL for First Time Leaners LTYusuke Kita
 
How to try! Swift
How to try! SwiftHow to try! Swift
How to try! SwiftYusuke Kita
 
SIL for the first time
SIL for the first timeSIL for the first time
SIL for the first timeYusuke Kita
 
Introducing protobuf in Swift
Introducing protobuf in SwiftIntroducing protobuf in Swift
Introducing protobuf in SwiftYusuke Kita
 
Type-safe Web APIs with Protocol Buffers in Swift at AltConf
Type-safe Web APIs with Protocol Buffers in Swift at AltConfType-safe Web APIs with Protocol Buffers in Swift at AltConf
Type-safe Web APIs with Protocol Buffers in Swift at AltConfYusuke Kita
 
Type-safe Web APIs with Protocol Buffers in Swift at iOSCon
Type-safe Web APIs with Protocol Buffers in Swift at iOSConType-safe Web APIs with Protocol Buffers in Swift at iOSCon
Type-safe Web APIs with Protocol Buffers in Swift at iOSConYusuke Kita
 
Command Line Tool in swift
Command Line Tool in swiftCommand Line Tool in swift
Command Line Tool in swiftYusuke Kita
 

More from Yusuke Kita (20)

Integrating libSyntax into the compiler pipeline
Integrating libSyntax into the compiler pipelineIntegrating libSyntax into the compiler pipeline
Integrating libSyntax into the compiler pipeline
 
Making your own tool using SwiftSyntax
Making your own tool using SwiftSyntaxMaking your own tool using SwiftSyntax
Making your own tool using SwiftSyntax
 
[Deprecated] Integrating libSyntax into the compiler pipeline
[Deprecated] Integrating libSyntax into the compiler pipeline[Deprecated] Integrating libSyntax into the compiler pipeline
[Deprecated] Integrating libSyntax into the compiler pipeline
 
Creating your own Bitrise step
Creating your own Bitrise stepCreating your own Bitrise step
Creating your own Bitrise step
 
Introducing swift-format
Introducing swift-formatIntroducing swift-format
Introducing swift-format
 
Unidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUIUnidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUI
 
Open Source Swift Workshop
Open Source Swift WorkshopOpen Source Swift Workshop
Open Source Swift Workshop
 
Contributing to Swift Compiler
Contributing to Swift CompilerContributing to Swift Compiler
Contributing to Swift Compiler
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in go
 
Writing an interpreter in swift
Writing an interpreter in swiftWriting an interpreter in swift
Writing an interpreter in swift
 
SIL Optimizations - AllocBoxToStack
SIL Optimizations - AllocBoxToStackSIL Optimizations - AllocBoxToStack
SIL Optimizations - AllocBoxToStack
 
SIL for First Time Learners
SIL for First Time LearnersSIL for First Time Learners
SIL for First Time Learners
 
var, let in SIL
var, let in SILvar, let in SIL
var, let in SIL
 
SIL for First Time Leaners LT
SIL for First Time Leaners LTSIL for First Time Leaners LT
SIL for First Time Leaners LT
 
How to try! Swift
How to try! SwiftHow to try! Swift
How to try! Swift
 
SIL for the first time
SIL for the first timeSIL for the first time
SIL for the first time
 
Introducing protobuf in Swift
Introducing protobuf in SwiftIntroducing protobuf in Swift
Introducing protobuf in Swift
 
Type-safe Web APIs with Protocol Buffers in Swift at AltConf
Type-safe Web APIs with Protocol Buffers in Swift at AltConfType-safe Web APIs with Protocol Buffers in Swift at AltConf
Type-safe Web APIs with Protocol Buffers in Swift at AltConf
 
Type-safe Web APIs with Protocol Buffers in Swift at iOSCon
Type-safe Web APIs with Protocol Buffers in Swift at iOSConType-safe Web APIs with Protocol Buffers in Swift at iOSCon
Type-safe Web APIs with Protocol Buffers in Swift at iOSCon
 
Command Line Tool in swift
Command Line Tool in swiftCommand Line Tool in swift
Command Line Tool in swift
 

Recently uploaded

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 

Recently uploaded (20)

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

Introducing Cardio

  • 3. MY FUTURE TALKS > Search APIs and Universal Links in practice @iOS9 bootcamp > Introducing new features for watchOS 2 @MOSA software meeting
  • 4. HEALTHKIT HealthKit allows apps that provide health and fitness services — HealthKit Framework Reference
  • 5. CLASSES > HKDevice > HKSample > HKObjectType > HKQuantity > HKUnit > HKQuery
  • 6. HKQUERY > HKSampleQuery > HKObserverQuery > HKAnchoredObjectQuery > HKStatisticsQuery > HKStatisticsCollectionQuery > HKCorrelation > HKSourceQuery
  • 7. HEART RATE IN WATCHOS-2-SAMPLER class HeartRateInterfaceController: WKInterfaceController { let healthStore = HKHealthStore() let heartRateType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeartRate)! let heartRateUnit = HKUnit(fromString: "count/min") var heartRateQuery: HKQuery? override func willActivate() { super.willActivate() guard HKHealthStore.isHealthDataAvailable() else { return } let dataTypes = Set([heartRateType]) healthStore.requestAuthorizationToShareTypes(nil, readTypes: dataTypes) { (success, error) -> Void in guard success else { return } } } @IBAction func fetchBtnTapped() { guard self.heartRateQuery == nil else { return } if self.heartRateQuery == nil { self.heartRateQuery = self.createStreamingQuery() self.healthStore.executeQuery(self.heartRateQuery!) } else { self.healthStore.stopQuery(self.heartRateQuery!) self.heartRateQuery = nil } } private func createStreamingQuery() -> HKQuery { let predicate = HKQuery.predicateForSamplesWithStartDate(NSDate(), endDate: nil, options: .None) let query = HKAnchoredObjectQuery(type: heartRateType, predicate: predicate, anchor: nil, limit: Int(HKObjectQueryNoLimit)) { (query, samples, deletedObjects, anchor, error) -> Void in self.addSamples(samples) } query.updateHandler = { (query, samples, deletedObjects, anchor, error) -> Void in self.addSamples(samples) } return query } private func addSamples(samples: [HKSample]?) { guard let samples = samples as? [HKQuantitySample] else { return } guard let quantity = samples.last?.quantity else { return } let heartRate = quantity.doubleValueForUnit(heartRateUnit) } }
  • 8. !
  • 11. FEATURES > Super simple to access HealthKit > Cuztomizable preferences > Well-designed for workout app > Easy way to save workout data in HealthKit
  • 13. INSTALLATION Carthage github "kitasuke/Cardio" Add HealthKit entitlements into both containing iOS app target and WatchKit Extension target
  • 14. CONTEXT PROTOCOL public protocol Context { var activityType: HKWorkoutActivityType { get } var locationType: HKWorkoutSessionLocationType { get } var distanceUnit: HKUnit { get } var activeEnergyUnit: HKUnit { get } var heartRateUnit: HKUnit { get } var distanceType: HKQuantityType { get } var activeEnergyType: HKQuantityType { get } var heartRateType: HKQuantityType { get } var shareIdentifiers: [String] { get } var readIdentifiers: [String] { get } }
  • 15. CONTEXT EXTENSION public extension Context { public var activityType: HKWorkoutActivityType { return .Running } public var locationType: HKWorkoutSessionLocationType { return .Outdoor } public var distanceUnit: HKUnit { return HKUnit.meterUnitWithMetricPrefix(.Kilo) } public var activeEnergyUnit: HKUnit { return HKUnit.kilocalorieUnit() } public var heartRateUnit: HKUnit { return HKUnit(fromString: "count/min") } ... }
  • 16. STRUCT CONFORMED CONTEXT struct CardioContext: Context { var locationType: HKWorkoutSessionLocationType { return .Indoor } var distanceUnit: HKUnit { return HKUnit.mileUnit() } var shareIdentifiers: [String] { return [] } }
  • 17. INITIALIZATION let context = CardioContext() cardio = Cardio(context: context)
  • 18. AUTHORIZATION WATCHKIT EXTENSION TARGET cardio.authorize { result in } CONTAINING IOS APP TARGET func applicationShouldRequestHealthAuthorization(application: UIApplication) { authorize() }
  • 19. UPDATE HANDLERS cardio.distanceHandler = { distance, total in } cardio.activeEnergyHandler = { activeEnergy, total in } cardio.heartRateHandler = { heartRate, average in }
  • 20. WORKOUT SESSION cardio.start { result in } cardio.end { result in }
  • 22.
  • 23.
  • 24. FUTURE WORK > Add more features > Fully support HealthKit > Make wrapper for iOS app target