Health and Fitness

RSS for tag

Use HealthKit to enable your iOS and watchOS apps to work with the Apple Health app.

Posts under Health and Fitness tag

56 Posts
Sort by:
Post marked as solved
1 Replies
393 Views
I noticed that there was the ECG app on the Apple Watch that enabled you to gather an ECG sample. Was there any method that could programmatically enable tracking within your own watchOS application? Currently, the only way I can physically get samples is if I leave the application I'm building to physically start an ECG session through the ECG app which is not ideal.
Posted
by reskrit.
Last updated
.
Post not yet marked as solved
0 Replies
322 Views
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 :)
Posted
by Fiecoor.
Last updated
.
Post not yet marked as solved
0 Replies
444 Views
Dear Apple Support Team, I am reaching out to inquire about the process to enable the health-related features of the Apple Watch Series 8 in Pakistan. Your valuable guidance and assistance in making these features accessible would be greatly appreciated. Thank you for your attention to this matter. Sincerely,
Posted
by ANK1979.
Last updated
.
Post not yet marked as solved
0 Replies
531 Views
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.
Posted
by TobinP.
Last updated
.
Post not yet marked as solved
0 Replies
417 Views
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.
Posted
by TobinP.
Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
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?
Posted
by donthedev.
Last updated
.
Post marked as solved
3 Replies
1.7k Views
This might be a silly question. Does anyone know if HealthKit is available for iPadOS 14? I see that it is now available for MacCatalyst 13.0+ in the documentation but iPadOS was not listed. Thanks, Casey
Posted
by cmb94.
Last updated
.
Post not yet marked as solved
1 Replies
1k Views
I have an iOS/wOS app that launched last year. Now I want to add complications to it and use the new way of doing complications with WidgetKit. I have everything in place up to the point where I'm supposed to read the data from Health to display it, where it fails with Missing com.apple.developer.healthkit entitlement. This is the new extension I've added It's embedded in the WatchKit app NOT in the WatchKit Extension and I've added permission to read health data directly in the info.plist for the extension I pull the data from the TimelineProvider protocol method func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { let currentDate = Date() var entries: [WorkoutEntry] = [] ComplicationHealthManager.loadPreviousWorkouts { workout in let workoutEntry = WorkoutEntry(date: currentDate, workout: workout) entries.append(workoutEntry) let timeline = Timeline(entries: entries, policy: .after(currentDate)) completion(timeline) } } with the help of a small manager class class ComplicationHealthManager: ObservableObject { static func loadPreviousWorkouts(completion: @escaping (HKWorkout?) -> Void) { let healthStore: HKHealthStore = HKHealthStore() let workoutPredicate = HKQuery.predicateForWorkouts(with: .traditionalStrengthTraining) let compound = NSCompoundPredicate(andPredicateWithSubpredicates: [workoutPredicate]) let sortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierEndDate, ascending: false) let query = HKSampleQuery( sampleType: .workoutType(), predicate: compound, limit: 0, sortDescriptors: [sortDescriptor]) { (query, samples, error) in guard let samples = samples as? [HKWorkout], error == nil else { completion(nil) return } let calendar = Calendar.current let todaysSamples = samples.filter{ calendar.isDateInToday($0.endDate) }.last completion(todaysSamples) } healthStore.execute(query) } } The issue is in the closure for the health query where it returns with no workouts but an error stating Error Domain=com.apple.healthkit Code=4 "Missing com.apple.developer.healthkit entitlement." UserInfo={NSLocalizedDescription=Missing com.apple.developer.healthkit entitlement.} The problem here is I don't understand where and how to add an entitlement for the complication extension or the WatchKit app, as none of them have the option for health. I have a health entitlements set for the iPhone app and the WatchKit Extension.
Posted
by trusk.
Last updated
.
Post not yet marked as solved
0 Replies
829 Views
Hello, I'm having a problem on my watchOS app where even though I have instantiated a WKExtendedRuntimeSession the app stops logging IMU data a few seconds after the watch has gone to sleep. This happens on my Apple Watch Series 6, but does not happen on the latest Apple Watch Series 8. CPU usage in both cases does not exceed 70%, so I doubt my app is exceeding the limits thus cancelling the WKExtendedRuntimeSession. To back that up, I am not getting the WKExtendedRuntimeSessionInvalidationReason trigger I was suggested to put in place form the documentation. I have tested a couple of different sample rates, this does not seem to happen with a sample rate as low as 1, but does happen already with a sample rate of 30. Could it be a watch limitation, or am I forgetting something? P.S. I have also set the background mode to physical therapy and ticket the workout processing box.
Posted
by NiccoGr.
Last updated
.
Post not yet marked as solved
0 Replies
483 Views
I have two related functions to retrieve the weather and then insert it into a "Live Workout Builder"... The first function calls the second to get the weather info after which it inserts the metadata into the builder. public func stopGatheringLocationData() { logger.info("Stopped gathering location data...") Task { let (humidity, temperature) = await getCurrentWeather() if humidity != nil && temperature != nil { logger.log("Current humidity \(humidity!), temperature: \(temperature!)") let metaData = [HKMetadataKeyWeatherHumidity: humidity!, HKMetadataKeyWeatherTemperature: temperature!] logger.log("Current metadata: \(metaData)") do { try await workoutManager.liveBuilder?.addMetadata(metaData) } catch { logger.error("FAILED to add weather metadata to workout -> \(error.localizedDescription)") } } else { logger.error("FAILED to retrieve weather data...") } } locationManager.stopUpdatingLocation() } private func getCurrentWeather() async -> (humidity: HKQuantity?, temperature: HKQuantity?) { // Get the weather for the starting location... let tempUnit = HKUnit.degreeFahrenheit() let humidityUnit = HKUnit.percent() guard let startingLocation else { logger.error("No starting location...") return (nil, nil) } do { let wx = try await wxService.weather(for: startingLocation) let humidity = wx.currentWeather.humidity let temp = wx.currentWeather.temperature.converted(to: .fahrenheit) let curWx = wx.currentWeather let wxAttr = try await wxService.attribution.legalAttributionText await MainActor.run { currentWx = curWx wxServiceAttribution = wxAttr } return (HKQuantity(unit: humidityUnit, doubleValue: humidity), HKQuantity(unit: tempUnit, doubleValue: temp.value)) } catch { logger.error("FAILED to retrieve weather data -> \(error.localizedDescription)") return (nil, nil) } } The two log statements in the first function print out the following information: [Location/Weather] Current humidity 52 %, temperature: 76.226 degF [Location/Weather] Current metadata: ["HKWeatherTemperature": 76.226 degF, "HKWeatherHumidity": 52 %] However, when I look at the workout in the Activity app on my iPhone, the map generated by my app is present but the weather information is missing. The data looks formatted correctly per the limited documentation but for some reason that data is just not showing up. Any help greatly appreciated...
Posted
by babt@ibm.
Last updated
.
Post not yet marked as solved
2 Replies
1.9k Views
Hello everyone, I just started watching the WWDC21 Code Along "Build a Research and Care App, Part 1" and wanted to run the project in Xcode. However, when I clone the Repo with the recommended git clone --recurse-submodule https://github.com/carekit-apple/WWDC21-RecoverApp.git command and open the project, I get the following error: /WWDC21-RecoverApp/Recover Part 1/Recover.xcodeproj This Copy Files build phase contains a reference to a missing file 'ResearchKit.framework'. /WWDC21-RecoverApp/ResearchKit only contains 2 files (CONTRIBUTING.md and LFS-Files). I was wondering how I could get the project up and running and if there are additional steps to take, that I didn't see in the presentation / Github Readme. Thanks!
Posted
by MxFx.
Last updated
.
Post not yet marked as solved
0 Replies
596 Views
Our app has a feature that requires retrieving the user's step count data. However, since September of last year, some users have reported that they are unable to retrieve their step count. Some of these users are on iOS 15, while others are on iOS 16. Additionally, some users have Apple Watch, while others do not. Recently, we received an error log stating Unable to invalidate interval: no data source available. However, we are not trying to fetch a large interval of data at once, and the program has a maximum time interval.We are unable to find the problem. We'd appreciate it if someone could help identify the issue. Thank you.
Posted
by Will_C.
Last updated
.
Post not yet marked as solved
0 Replies
787 Views
Is it possible to create a custom HealthKit sample type? Let's say for example I want to tack how many alcoholic beverages are consumed? Or how many times a user smokes each day? There is not a category in HealthKit for these today is it possible for my app to add them as custom data types?
Posted Last updated
.