try to fix watch stuff
This commit is contained in:
41
iphone/Werkout_watch Watch App/WatchDelegate.swift
Normal file
41
iphone/Werkout_watch Watch App/WatchDelegate.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// 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)))")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user