I have an App in objective-c that is using Health data (walk/run, cycling) to give advice to users . I do not want/need to write any data in the Healtkit.
If i do (with the 3 values in the plist / .info :
self.healthStore requestAuthorizationToShareTypes:nil readTypes:readDataTypes
My request crashes.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Must request authorization for at least one data type'
*** First throw call stack:
(
0 CoreFoundation 0x00000001804b910c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x0000000180092da8 objc_exception_throw + 72
2 CoreFoundation 0x00000001804b901c -[NSException initWithCoder:] + 0
3 HealthKit 0x000000019da034d4 -[HKHealthStore _validateAuthorizationRequestWithShareTypes:readTypes:] + 92
4 HealthKit 0x000000019da03670 -[HKHealthStore requestAuthorizationToShareTypes:readTypes:shouldPrompt:completion:] + 292
BUT in swift :
healthStore.requestAuthorization(toShare: nil, read: readTypes)
is working, présents only my 2 datas to read... in the same IOS , same phone without crashing. What is the difference ?
Nil object in objective-c and Nil object in swift are not the same ? how do i make readonly requests in objective C ?
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.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I’m trying to associate heart rate (HR) data with a mindfulness session (HKCategoryTypeIdentifier.mindfulSession) in HealthKit, but I can’t find any documentation on how to do this.
I’ve seen third-party apps (like Medito) successfully log HR within Mindful Minutes, even when the session takes place on an iPhone (not an Apple Watch). However, when I try saving HR in the metadata, it does not appear in the Health app's Mindful Minutes section.
Code snippet:
func logMindfulnessSession(start: Bool, heartRate: Double? = nil) {
let mindfulType = HKCategoryType.categoryType(forIdentifier: .mindfulSession)!
let now = Date()
let endTime = now.addingTimeInterval(Double(selectedDuration))
var metadata: [String: Any]? = nil
if let hr = heartRate {
let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute())
let hrQuantity = HKQuantity(unit: heartRateUnit, doubleValue: hr)
metadata = ["heartRate": hrQuantity] // ❓ Is there a correct key for HR?
}
let sample = HKCategorySample(
type: mindfulType,
value: 0,
start: now,
end: endTime,
metadata: metadata
)
healthStore.save(sample) { success, error in
if let error = error {
print("HealthKit session save error: \(error.localizedDescription)")
} else {
print("Mindfulness session saved successfully.")
if let hr = heartRate {
print("Saved with HR: \(hr) BPM")
}
}
}
}
Questions:
What is the correct metadata key for associating heart rate with a mindful session?
Does HealthKit require a specific format (e.g., HKQuantitySample) for HR?
0 Are there additional permissions needed to allow HR to appear in Mindful Minutes?
Does HR need to be stored separately in HKQuantityTypeIdentifier.heartRate, and if so, how do third-party apps ensure it appears in the same entry as the mindful session?
thank you!
I've searched all the App Intent and AssistantSchemas related documentation and I can't find anything related to workout, do I still need to use SiriKit?
Hi,
Need input on making ICEcard app paid version , requirements. The app is presently live for India and shortly will be for global. This app is for primary health information which is critical in case anyone faces emergency. Will it have any regulatory concerns ?
https://apps.apple.com/in/app/ice-card-app/id6736453602
Topic:
App & System Services
SubTopic:
Health & Fitness
I cannot access my corporate invoice. I don't know why I couldn't reach it. How and where can I reach it?
Topic:
App & System Services
SubTopic:
Health & Fitness
Dear Apple Developer Support,
I hope this message finds you well. I am reaching out for guidance on a project that involves sharing heart rate data between an iOS app and an Android app. I have developed a watchOS app that continuously fetches heart rate data from an Apple Watch and displays it in a companion iOS app. Additionally, I have built an Android fitness app using Ionic Angular.
My goal is to create a bridge that allows the heart rate data from the iOS app to be displayed continuously in the Android app. I am considering using a backend server (e.g., Node.js) to facilitate this data transfer.
Could you please provide any insights or recommendations on the best approach for achieving this cross-platform data sharing? I would appreciate any guidance on potential challenges or limitations I might encounter.
Thank you for your time and assistance.
Sincerely,
Venu Madhav
Topic:
App & System Services
SubTopic:
Health & Fitness
Tags:
App Tracking Transparency
CloudKit
Network
Cloud and Local Storage
The background deliver works perfectly when the app is in the background or suspended states. However, when the app is killed (terminated state), the background task does not execute
Platform & Version:
iOS Version: 18.3.1
Development Environment: Xcode 16.2, macOS 14.6.1
Description of the Issue:
We're exploring ways to better integrate Apple Fitness+ workouts into our app. We've noticed that some third-party apps, such as Strava and HealthFit, now display Fitness+ workout details, including the title, trainer, and an image.
I’ve been investigating how this is possible, and the only relevant change I’ve found is that HKMetadataKeyAppleFitnessPlusCatalogIdentifier is now being set for Fitness+ workouts. However, I can’t find any public API or official documentation that explains how to use these identifiers to retrieve the associated workout details.
Question:
Is there an official API available to fetch metadata for Fitness+ workouts using these identifiers? Or are these third-party apps potentially accessing private APIs? If no API exists, is the only option to create a manual mapping of these identifiers—something that seems impractical given the constantly evolving Fitness+ workout catalog?
Any guidance on this would be greatly appreciated. Thanks!
Topic:
App & System Services
SubTopic:
Health & Fitness
Tags:
Health and Fitness
HealthKit
WorkoutKit
Apple Watch automatically tracks sleep data and syncs it to the iPhone, making it available through HealthKit for historical analysis. However, there is no way to retrieve real-time data on whether a user has entered sleep, or whether they are in a specific sleep stage at any given moment.
Is it possible to provide an interface for real-time sleep status monitoring
Dear Apple Developer Support,
I am writing to request assistance with an ongoing issue I'm encountering while developing an iOS application that utilizes HealthKit to fetch heart rate data.
My goal is to display near real-time heart rate updates continuously same as displaying in the Apple Watch , I want to show in the iPhone Mobile Application for fitness related. I have implemented the following approaches:
HKSampleQuery with a Timer: I've set up a timer to periodically fetch the latest heart rate data.
Despite these efforts, I'm consistently facing the following problems:
Delayed Updates: The heart rate data displayed in the app often doesn't reflect the current heart rate being measured by the Apple Watch. There seems to be a significant synchronization delay.
Inconsistent Background Updates: Background updates, even with background app refresh enabled, are not reliable. The app often only updates when brought to the foreground or after being killed and relaunched.
Entitlements: The com.apple.developer.healthkit.background-delivery entitlement error is missing.
I have thoroughly reviewed Apple's HealthKit documentation, implemented best practices for HealthKit integration, and verified that all necessary permissions are properly configured.
I understand that HealthKit may not be designed for true real-time data, but the current level of delay and inconsistency is making it difficult to provide a useful user experience.
Could you please provide guidance on whether achieving near real-time heart rate updates continuously in an iOS app using HealthKit is possible? If so, what are the recommended strategies and best practices to overcome these limitations?
I have also tested the application on physical devices with Apple Watch, enabled background app refresh, granted permissions, and referred to HealthKit documentation.
I would appreciate any insights or suggestions you can offer to help resolve this issue.
Thank you for your time and assistance.
Sincerely,
Venu Madhav
Hi, I have an iPhone/watch app that measures walking/running distance. It starts a workout session records data successfully into healthkit and then ends the workout session. I can see the data in the Health app from my app and it all appears to be correct. The issue I'm having is that the Health app doesn't use my app's data in its total distance for the day. For example, I can add 1 mile of fake data (I know that's not allowed per policy) for testing and it gets successfully added but not used in the total. The health app is only using distances collected by the watch and the phone for calculating the total distance for the day and is ignoring the distance provided by my app. What could I be missing?
Topic:
App & System Services
SubTopic:
Health & Fitness
I have auth bloodPressureDiastolic and bloodPressureSystolic,
I can sync my bloodpressure data from my app to healthkit,
but My app listed as inactive under the Data Sources and Access of Health App
Topic:
App & System Services
SubTopic:
Health & Fitness
HKHealthStore().execute(query) run in main thread it cost 3.5s
here is my code
print("execute begin:(Date().timeIntervalSince1970)")
HKHealthStore().execute(query)
print("execute end:(Date().timeIntervalSince1970)")
query.predicate like this
(startDate >= CAST(0.000000, "NSDate") AND endDate < CAST(0.100000, "NSDate") AND startDate < CAST(0.100000, "NSDate")) OR (startDate >= CAST(60.000000, "NSDate") AND endDate < CAST(60.100000, "NSDate") AND startDate < CAST(60.100000, "NSDate")) OR (startDate >= CAST(120.000000, "NSDate") AND endDate < CAST(120.100000, "NSDate") AND startDate < CAST(120.100000, "NSDate")) OR (startDate >= CAST(180.000000, "NSDate") AND endDate < CAST(180.100000, "NSDate") AND startDate < CAST(180.100000, "NSDate")) OR (startDate >= CAST(240.000000, "NSDate") AND endDate < CAST(240.100000, "NSDate") AND startDate < CAST(240.100000, "NSDate")) OR (startDate >= CAST(300.000000, "NSDate") AND endDate < CAST(300.100000, "NSDate") AND startDate < CAST(300.100000, "NSDate")) OR (startDate >= CAST(360.000000, "NSDate") AND endDate < CAST(360.100000, "NSDate") AND startDate < CAST(360.100000, "NSDate")) OR (startDate >= CAST(420.000000, "NSDate") AND endDate < CAST(420.100000, "NSDate") AND startDate < CAST(420.100000, "NSDate")) OR (startDate >= CAST(480.000000, "NSDate") AND endDate < CAST(480.100000, "NSDate") AND startDate < CAST(480.100000, "NSDate")) OR (startDate >= CAST(540.000000, "NSDate") AND endDate < CAST(540.100000, "NSDate") AND startDate < CAST(540.100000, "NSDate")) OR (startDate >= CAST(600.000000, "NSDate") AND endDate < CAST(600.100000, "NSDate") AND startDate < CAST(600.100000, "NSDate")) OR (startDate >= CAST(660.000000, "NSDate") AND endDate < CAST(660.100000, "NSDate") AND startDate < CAST(660.100000, "NSDate")) OR (startDate >= CAST(720.000000, "NSDate") AND endDate < CAST(720.100000, "NSDate") AND startDate < CAST(720.100000, "NSDate")) OR (startDate >= CAST(780.000000, "NSDate") AND endDate < CAST(780.100000, "NSDate") AND startDate < CAST(780.100000, "NSDate")) OR (startDate >= CAST(840.000000, "NSDate") AND endDate < CAST(840.100000, "NSDate") AND startDate < CAST(840.100000, "NSDate")) OR (startDate >= CAST(900.000000, "NSDate") AND endDate < CAST(900.100000, "NSDate") AND startDate < CAST(900.100000, "NSDate")) OR (startDate >= CAST(960.000000, "NSDate") AND endDate < CAST(960.100000, "NSDate") AND startDate < CAST(960.100000, "NSDate")) OR (startDate >= CAST(1020.000000, "NSDate") AND endDate < CAST(1020.100000, "NSDate") AND startDate < CAST(1020.100000, "NSDate")) OR (startDate >= CAST(1080.000000, "NSDate") AND endDate < CAST(1080.100000, "NSDate") AND startDate < CAST(1080.100000, "NSDate")) OR (startDate >= CAST(1140.000000, "NSDate") AND endDate < CAST(1140.100000, "NSDate") AND startDate < CAST(1140.100000, "NSDate")) OR (startDate >= CAST(1200.000000, "NSDate") AND endDate < CAST(1200.100000, "NSDate") AND startDate < CAST(1200.100000, "NSDate")) OR (startDate >= CAST(1260.000000, "NSDate") AND endDate < CAST(1260.100000, "NSDate") AND startDate < CAST(1260.100000, "NSDate")) OR (startDate >= CAST(1320.000000, "NSDate") AND endDate < CAST(1320.100000, "NSDate") AND startDate < CAST(1320.100000, "NSDate")) OR (startDate >= CAST(1380.000000, "NSDate") AND endDate < CAST(1380.100000, "NSDate") AND startDate < CAST(1380.100000, "NSDate")) OR (startDate >= CAST(1440.000000, "NSDate") AND endDate < CAST(1440.100000, "NSDate") AND startDate < CAST(1440.100000, "NSDate")) OR (startDate >= CAST(1500.000000, "NSDate") AND endDate < CAST(1500.100000, "NSDate") AND startDate < CAST(
Log
execute begin:1739958803.531026
execute end:1739958807.0448961
Topic:
App & System Services
SubTopic:
Health & Fitness
Dear Apple Developers,
Could you kindly add the two following workout types to your Apple Watch? There are large communities that participate in both of these activities globally.
Rucking workout option. goruck.com
TRX suspension trainer option. trxtraining.com
Thank you for your consideration. This addition will make many people happy.
Topic:
App & System Services
SubTopic:
Health & Fitness
I have a strange situation and I'm not sure where else to post this. Our app's domain (or at least its API hostname in the domain) resolves to something different only inside of Apple's network.
I was able to get an Apple employee to verify this by resolving the API hostname while on Apple's corporate network and it resolves to an IP that is in Apple's 17.0.0.0/8 network, but everywhere else resolves to the normal IPs. Our domain's DNS is provided by Cloudflare and they are not doing anything special for Apple's network.
This is causing problems during App Review because the app is trying to reach our API to log in and instead is being routed to an IP in Apple's network, so it fails SSL validation and presents an error dialog. App Review is then claiming our app doesn't work and rejecting it. This is an app that has been in the App Store for over a decade and gone through countless app reviews.
App Review was of no help resolving this and I don't know where else to turn. How can I find out why our domain is being rerouted inside of Apple and get this fixed?
Topic:
App & System Services
SubTopic:
Health & Fitness
In the fitness app under iOS 18, the location of all workouts is displayed on a small map.
For workouts with routes, I can already successfully read out the route and thus also determine the starting point. So that works.
For indoor workouts such as yoga or indoor rowing, the exact location is also displayed in the fitness app. I would now also like to read out this location for these indoor workouts in my app.
Does anyone know how to do this?
I can create WorkoutGoals of all kinds except .energy, but I can't find any indication of the conditions under which energy goals can be used.
No matter what I try, the response from supportsGoal is always false e.g.
CustomWorkout.supportsGoal(.energy(10, .kilojoules), activity: .running, location: .outdoor)
CustomWorkout.supportsGoal(.energy(10, .calories), activity: .cycling, location: .outdoor)
CustomWorkout.supportsGoal(.energy(10, .kilocalories), activity: .running, location: .outdoor)
For any combination I've tried, I get Not supported due to unsupportedGoal
Has anybody managed to successfully create energy goals?
I am working on an Apple Watch companion app to an existing live iOS app. I am utilizing the heart rate tracking for an active 'self-care' sauna session. I say self-care in quotes because it's more self-care than a workout activity, but it is closely blurring the lines between the two.
I have come to understand that if a session truly isn't a workout, then you should not use workoutSession.startActivity. However the app needs to function entirely like a workout would. This is not a meditation application. Sauna is actually just one of many activity types supported in the app.
I have tried using extended runtime session, and there have been numerous issues with doing so. It is not nearly as robust for the user. For example, the active session is not prioritized by the watch's CPU. Now playing is no longer functional. Heart rate is far more inconsistent, and this variable is as critical as if it were in a workout.
I have tried using HKWorkoutSession, however I worry the app will be rejected by doing so. This method works most accurately to collect the right data for the user, and prioritizes system resources as expected. The app can be moved to the background as expected and continue to communicate with the iOS app.
What is the best way to move forward here. It almost feels like I am operating in a grey area with no real solution in place. Any assistance is greatly appreciated as we would like to follow all guidelines while producing a high quality experience for our users.
Any idea to achieve reliable periodic Bluetooth data retrieval on iOS, even when the app is closed or killed.
I am using a new Apple Watch Ultra 2 (MX5R3LW/A) running WatchOS 11.3 (22S553).
I noticed that the watch often misses heart measurements during meaningfully long segments of exercise sessions. This has been bugging me for a while and today I read an article that described perfectly, and much better than I could, what I am experiencing. Here is the article: https://apple.news/AK_QJyoLaQ1eaeySWHlkLPw
Is this a known issue that is being worked?
Thanks.
Topic:
App & System Services
SubTopic:
Health & Fitness