Hello all, this could surely be a newbie mistake but I'm unable to adopt this protocol to my class object I've created in a new project.
The Error: "Cannot find type 'OCKSurveyTaskViewControllerDelegate' in scope"
import CareKit
import CareKitUI
import CareKitStore
import ResearchKit
import UIKit
import os.log
final class CareFeedViewController: OCKDailyPageViewController, OCKTaskSurveyViewControllerDelegate {
}
However, I've been able to locate the 'OCKSurveyViewController.swift" file in the CareKit framework from SPM which has the protocol defined there, but I'm still unable to utilize it. Was the protocol only for demonstration purposes and not for use outside of the WWDC21 - CareKit Code Along?
Health & Fitness
RSS for tagExplore the technical aspects of health and fitness features, including sensor data acquisition, health data processing, and integration with the HealthKit framework.
Post
Replies
Boosts
Views
Activity
I am receiving the following crash when trying to query data from health kit.
It seems to be complaining about end date being before start date however with the values I am passing in that is not possible.
Also I tried to purposefully pass in end dates before start date and I still was not able to reproduce this crash.
I have attached my code snippet and the crash logs here.
Please Help :(
self.statisticfetcher(
type: HKObjectType.quantityType(forIdentifier: .bodyMass),
options: .discreteAverage,
metricType: .bodyWeight,
statsHandler:
{ stats in
if let quantity = stats.averageQuantity() {
...
}
return nil
})
private func statisticfetcher(
type: HKQuantityType?,
options: HKStatisticsOptions,
metricType: HealthMetricType,
statsHandler: @escaping (HKStatistics) -> BASchema.HealthDataEntryInput?,
resultHandler: ((HKStatisticsCollection?, Date, Date, Error?) -> Void)? = nil)
{
let res = getStartEndDate()
let endDate = res.endDate
let startDate = res.startDate
guard let type = type else {
return
}
let query = HKStatisticsCollectionQuery(quantityType: type,
quantitySamplePredicate: nil,
options: options,
anchorDate: startDate,
intervalComponents: DateComponents(day: 1))
let defaultResultHandler: (HKStatisticsCollection?, Date, Date, Error?) -> Void = { statCollection, startDate, endDate, error in
if let error = error {
return
}
guard let statCollection = statCollection else {
return
}
statCollection.enumerateStatistics(from: startDate, to: endDate) { stats, _ in
...
}
}
let resultHandler = resultHandler ?? defaultResultHandler
query.initialResultsHandler = { _, statCollection, error in
resultHandler(statCollection, startDate, endDate, error)
}
query.statisticsUpdateHandler = { _, _, statCollection, error in
resultHandler(statCollection, startDate, endDate, error)
}
self.store.execute(query)
self.subscribeToBackgroundDelivery(type: type)
}
private func subscribeToBackgroundDelivery(type: HKObjectType) {
store.enableBackgroundDelivery(for: type, frequency: .immediate) { success, error in
if(error != nil && !success) { print("Background Delivery for \(type) Failed!") }
}
}```
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x9cb4 __exceptionPreprocess
1 libobjc.A.dylib 0x183d0 objc_exception_throw
2 Foundation 0x4e156c _userInfoForFileAndLine
3 HealthKit 0xe0d2c -[HKDateInterval initWithStartDate:endDate:]
4 HealthKit 0xc7a5c -[NSDateComponents(HealthKit) hk_dateIntervalForDate:anchorDate:outIndex:]
5 HealthKit 0x1a0f98 -[HKStatisticsCollection _statisticsDateIntervalAndIndex:forDate:]
6 HealthKit 0x1a0420 -[HKStatisticsCollection _insertStatistics:]
7 HealthKit 0x1a059c -[HKStatisticsCollection _resetStatistics:]
8 HealthKit 0x19efc8 -[HKStatisticsCollectionQuery _queue_deliverResetStatisticsObjects:forQuery:]
9 HealthKit 0x19e8bc __98-[HKStatisticsCollectionQuery client_deliverStatisticsBatch:resetStatistics:isFinal:anchor:query:]_block_invoke
10 libdispatch.dylib 0x2320 _dispatch_call_block_and_release
11 libdispatch.dylib 0x3eac _dispatch_client_callout
12 libdispatch.dylib 0xb534 _dispatch_lane_serial_drain
13 libdispatch.dylib 0xc0d8 _dispatch_lane_invoke
14 libdispatch.dylib 0x16cdc _dispatch_workloop_worker_thread
15 libsystem_pthread.dylib 0xddc _pthread_wqthread
16 libsystem_pthread.dylib 0xb7c start_wqthread
I would love to chat with someone around the possibilities surrounding healthcare and visionOS. I would LOVE to work with incorporating VisionOS into my SIMLab, especially for my surgery residents and eventually with my virtual providers.
I am building an app that requires real time (minute level) body temperature data. I couldn't find the api to do that. Does HealthKit offer this data?
I am unable to see the workout composition from preview in the new WorkoutKit framework.
This is reproducible on an iPhone running iOS 17.0 running xcode 15.0 beta 2.
I downloaded the Sample Planner app that showcases the new WorkoutKit framework capabilities , introduced in the session 10016 of wwdc 23.
I can create workout compositions but the preview presentation doesn’t work as expected. It shows a black screen without any info. I attached a screenshot.
You can reproduce it on the sample app when showing the PresentPreviewDemo view.
I'm trying to make a simple workout app that gets data from the health app (not an app that you use the record the actual workout). I can get data from the health app and manually add workouts but I couldn't find out how to record one with a map. Is there a way for me to either upload a GPX file for the workout, record it on the watch, or some other way to get the workout with a map on the simulator.
Hi! I am trying to build a fitness app and running it on an iPhone simulator. So far, the app is working and can detect workouts and display them. Now, I want to make the app work for workouts that have a map but I couldn't find how to add a map or any other kind of data without recording it on the apple watch which I can't do because there is no workout app displayed on the simulated watch. Thanks.
Has anyone used healthDataAccessRequest successfully in SwiftUI? How does parameter trigger work?
I have a question regarding the number of steps that can be retrieved from HealthKit.
Is there any difference in the result of the number of steps when the number of steps is acquired immediately after walking and when it is acquired 10 minutes later?
For example, the following image.
First, the data is acquired from HealthKit and 0 steps are returned.
Within 1 minute, the user takes 50 steps.
Immediately after taking 50 steps, data is retrieved from HealthKit and 0 steps are returned.
After 10 minutes, HealthKit retrieves data and returns 50 steps without taking a single step.
Sometimes the correct number of steps is obtained immediately after walking, and sometimes the correct number of steps is not obtained until some time has elapsed.
So, I've wrote the following code;
let status = healthStore.authorizationStatus(for: .activitySummaryType())
switch status {
case .notDetermined:
return false
case .sharingDenied:
return false
case .sharingAuthorized:
return true
@unknown default:
return false
}
And it is hitting the .sharingDenied case. This doesn't make sense as on my phone I have allowed read access (there's no sharing option per the documentation). As soon as I change out to let's say;
let checkHkQuantityTypeAuthorization = HKObjectType.quantityType(forIdentifier: .stepCount)
I am able to hit the case .sharingAuthorized case. What doesn't make sense is that even though it fails this check, if I just go ahead and query for the Activity Summary for the ring data via;
let predicate = HKQuery.predicate(forActivitySummariesBetweenStart: startDateComponents, end: endDateComponents)
let query = HKActivitySummaryQuery(predicate: predicate) { (query, summaries, error) { ... }
It works just fine and I can pull the Activity data without changing any permissions in the Privacy settings of my iPhone or iPad. So, I know I can pull the data just fine, and that everything is set correctly for the Entitlements.
I just want to make sure that the user has actually allowed me to before I try to pull the data.
Additional Notes: The REALLY weird thing is that that when I try to pull the .stepCount, is that it will hit the .sharingDenied case if I only have the user do READ access. So, I've had to make my app also request for WRITE (share) access.
Like this doesn't make any sense for me to request both READ and WRITE access to step count when my app only needs read access (like Activity Summary data). This seems like a bug in my opinion as I don't see anything related in the documentation in regards to this on the
If this is how this is supposed to work given the discussion on the documentation;
To help prevent possible leaks of sensitive health information, your app cannot determine whether or not a user has granted permission to read data. If you are not given permission, it simply appears as if there is no data of the requested type in the HealthKit store. If your app is given share permission but not read permission, you see only the data that your app has written to the store. Data from other sources remains hidden.
Source: https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus
Then that is completely confusing. I want to check if I have permissions to read this data otherwise why bother trying to read the data or try to present anything to the user except that they need to allow access to me reading this data.
Apple says that you should only request to relevant Health data when you need it. So this check is worthless if I am trying to check before I do the query because the UI wants to display data in regard to activity data.
Honestly, this is really confusing if all this falls into the discussion item on the documentation and Apple needs to do better.
EDIT: Further reading the very top of the method definition yields;
Returns the app’s authorization status for sharing the specified data type.
Like why Apple? I want to know if I can READ the type so I can tell the user to allow me access or not. This is frustrating.
I would like to initialize a HKDeletedObject for an unit test. Before diving into NSCoder: Has somebody done this before and can give some advice? Thanks in advance!
Is it possible to build a watch app that has real time access to sleep stages and could determine whether a user is asleep?
Hello, I'm trying to understand what's the difference between:
HeartRateZoneAlert: static func heartRate(zone: Int) -> Self
PowerZoneAlert : static func power(zone: Int) -> Self
And also, why HeartRate alerts support range, but Power doesn't support Range?
Hello,
The new mental health features in iOS 17 allow users to log their momentary emotions and daily moods, see valuable insights, and easily access assessments and resources. Does anyone know if HealthKit in iOS 17 provides an API for accessing these records? Thanks :)
Hello,
I use iPhone 14 Pro with iOS 17 Beta, my girlfriend use iPhone 13 with newest iOS 16. We used to use Fitness application to share our daily activity (steps, kcals etc.) Unfortunately last time our activity progress doesn't shows properly. In my phone I have 1000 steps for example, my gf see 0 steps. The same was at I was on iOS 16. Removing and invitating again doesn't help. What can we check?
Thanks in advance :)
I tried the sample code from 'Customizing workouts with WorkoutKit' all works fine on the simulator, however, I have the following error when testing on device (iPhone SE):
Error Domain=WorkoutKit.StateError Code=0 "(null)"
On launch, this is associated with 'failed to retrieve scheduled plans'. Also the same when requesting authorization.
Any ideas on this one?
Will Apple Vision Pro support medical imaging diagnostic software such as Horos or Osirix. I am really curious if radiologist will be able to view and manipulate. interpret exams with this headset with ease and use built in microphone for voice recognition/dictation while using hands to manipulate the imaging and also simultaneously being able to view report in field of view. This could really unlock some major potential for interpreting at least CT, Ultrasound and MRI exams. I don't think the resolution will be high enough to interpret diagnostic x-rays and definitely not mammograms due to MQSA regulations and physicist inspections requiring more detail and information. However, I want to be at the forefront of bringing in Vision Pro headsets in the medical imaging space with rel utilization in clinical practices. It may also be beneficial for patients who are curious to see their medical imaging or even as headsets to use while undergoing medical imaging outpatient biopsy procedures for ******/etc to help put them at ease during the procedures. This could really provide patient satisfaction and I think we are scratching the surface on a world of possibilities in healthcare with devices like this. Upon utilixation, I would like to creat presentation series and share information with my Radiology colleagues at national/international meetings.
The "func workoutBuilder(_ workoutBuilder: HKLiveWorkoutBuilder, didCollectDataOf collectedTypes: Set)" function from the "HKLiveWorkoutBuilderDelegate" is not updating data from "HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned)" in a workout session.
My app is using the same code as before and it stopped working since I updated my watch to the version 9.6.1(20U80). I am using Xcode 14.3.1 (14E300c). Is there any solution to address this matter?
I'm using Xcode Version 15.0 beta (15A5160n) and getting the following error:
Value of type 'HKWorkoutSession' has no member 'sendToRemoteWorkoutSession'
Any idea what's causing this? I pulled the code from https://developer.apple.com/videos/play/wwdc2023/10023/
Hi,
i am developing an app to enter audiogram data to Apple HealthKit and i want to have a little more information about Apple‘s headphone accommodation.
is there any information about how the accommodation exactly works? Which filters will be applied in the background?
How are the filter coefficients created etc.?
Is there any access to the resulting eq curve?
Is there also dynamic compression used in a certain way?
Kind regards,
Tom