Files
WerkoutIOS/iphone/Werkout_watch Watch App/WatchDelegate.swift
2024-07-01 21:22:12 -05:00

42 lines
1.1 KiB
Swift

//
// WatchDelegate.swift
// Werkout_watch Watch App
//
// Created by Trey Tartt on 7/1/24.
//
import WatchKit
import HealthKit
class WatchDelegate: NSObject, WKApplicationDelegate {
func applicationDidFinishLaunching() {
autorizeHealthKit()
}
func applicationDidBecomeActive() {
}
func applicationWillResignActive() {
}
func handle(_ workoutConfiguration: HKWorkoutConfiguration) {
// WatchWorkout.shared.startWorkout()
}
func autorizeHealthKit() {
let healthKitTypes: Set = [
HKObjectType.quantityType(forIdentifier: .heartRate)!,
HKObjectType.quantityType(forIdentifier: .activeEnergyBurned)!,
HKObjectType.quantityType(forIdentifier: .oxygenSaturation)!,
HKQuantityType.workoutType()
]
HKHealthStore().requestAuthorization(toShare: healthKitTypes, read: healthKitTypes) { (succ, error) in
if !succ {
fatalError("Error requesting authorization from health store: \(String(describing: error)))")
}
}
}
}