Posts

Post marked as solved
1 Replies
1.3k Views
My App with outdoor-running activity type receives HKWorkoutEvent.motionPaused und HKWorkoutEvent.motionResumed events from HKLiveWorkoutBuilderDelegate, even if the User toggled the feature off in the workout settings (Settings -> Workout -> Auto-Pause). I guess this is unexpected behavior (FB11754136), but is there a way to check the user preference from the watchOS settings? Kind regards, Josh
Posted Last updated
.
Post not yet marked as solved
1 Replies
883 Views
Hi. I'm developing a running App for WatchOS. During onboarding I ask for location permission in order to save the workout route. I use requestWhenInUseAuthorization()on a CLLocationManager. Since WatchOS 8, I have encountered some weird behavior. After a while the permission seems to "reset" without any interaction by the user or the App. When I check the permission in WatchOS, its state is "Ask or When I Share". Am I'm missing something or is it a bug? I'm also unable to change the permissions in settings.
Posted Last updated
.
Post marked as solved
1 Replies
722 Views
I'm developing a running App for WatchOS. I implemented workout restoration as described here: https://developer.apple.com/documentation/watchkit/wkextensiondelegate/2976310-handleactiveworkoutrecovery. Unfortunately, it only works when a crash occurs. When the user closes the App during a workout, the session still remains and there's no way to end it when the user relaunches the App. Is there any way to retrieve the active session and restore the session like HKHealthStore().recoverActiveWorkoutSession?
Posted Last updated
.
Post not yet marked as solved
1 Replies
1k Views
Hi there, I'm trying to read workouts from a WatchOS App. Unfortunately, the returned workouts are always empty. This is how it's currently implemented: func fetchWorkouts(limit: WorkoutLimit) async throws -> [HKWorkout] { let activityType = PulseConfiguration.activityType // 1. Get all workouts with the configured activity type. let walkingPredictate = HKQuery.predicateForWorkouts(with: activityType) // 2. Get all workouts that only came from this app. let sourcePredicate = HKQuery.predicateForObjects(from: .default()) // 3. Combine the predicates into a single predicate. let compound = NSCompoundPredicate(andPredicateWithSubpredicates: [walkingPredictate, sourcePredicate]) let sortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierEndDate, ascending: false) typealias WorkoutsContinuation = CheckedContinuation<[HKWorkout], Error> return try await withCheckedThrowingContinuation { (continuation: WorkoutsContinuation) in let query = HKSampleQuery( sampleType: .workoutType(), predicate: compound, limit: limit.count, sortDescriptors: [sortDescriptor] ) { _, samples, error in guard let samples = samples as? [HKWorkout], error == nil else { if let error = error { continuation.resume(throwing: error) } return } continuation.resume(returning: samples) } healthStore.execute(query) } } I noticed that the HKSource returned by .default (WatchOS) is different than the source associated to the saved workouts (Which contains the bundle identifier from the iPhone App). Is there some other way to access the workouts from the WatchOS App? Thanks in advance. Josh.
Posted Last updated
.
Post not yet marked as solved
0 Replies
824 Views
I'm going to test a function which fetches the heart-rate using a HKSampleQuery. The test failes with the error: Missing com.apple.developer.healthkit entitlement.The App itself works fine. I added the entitlement to the target but I'm not able to add it to the Test-Target.Is it possible to configure the test-target to include the same capabilities as the executable target?I'm using Xcode Version 11.1 (11A1027) and SwiftPM as package manager. The tests are executed using the new TestPlan feature.Thank you in advance.Josh.
Posted Last updated
.