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

72 Posts
Sort by:
Post not yet marked as solved
0 Replies
205 Views
How do I remove a step data source in the Health app? Some of the devices are out of use now and I'd like to remove them from my Health data, but now it seems I can only drag them to the bottom in the priority list but am not able to remove them completely.
Posted
by Yvette123.
Last updated
.
Post not yet marked as solved
0 Replies
247 Views
Hi, I am writing workout app for WatchOS and want to add activeEnergyBurned sample whenever user has finished exercise in workout. But whenever I add sample to builder it returns that it was successfully added but when checking added samples in Health app, it shows that it is always 0 and also sum of samples is also always 0. Does activeEnergyBurned has some additional requirements because when tried to write basalEnergyBurned it successfully wrote given calories. Writing sample here:     let energyBurnedType = HKObjectType.quantityType(forIdentifier: .activeEnergyBurned)     if energyBurnedType != nil {       let energyBurned = HKQuantity(unit: HKUnit.largeCalorie(), doubleValue: Double(totalCalories))       let energyBurnedSample = HKQuantitySample(type: energyBurnedType!, quantity: energyBurned, start: self.exerciseStart, end: Date())       builder.add([energyBurnedSample]) { (success, error) in         print(success)         print(error)       }     } And reading data that always returns 0: func updateForStatistics(_ statistics: HKStatistics?) {     guard let statistics = statistics else { return }           DispatchQueue.main.async {       switch statistics.quantityType {       case HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned):         let energyUnit = HKUnit.largeCalorie()         let value = statistics.sumQuantity()?.doubleValue(for: energyUnit)         self.activeCalories = Double( round( 1 * value! ) / 1 )         print(value)         return       default:         return       }     }   } Any ideas on what am I missing? I checked my workout recordings and I see that samples get added but doesn't affect total active energy shown in Health app: And here you can see that sample is added:
Posted Last updated
.
Post not yet marked as solved
1 Replies
494 Views
If I use the Apple training app for indoor swim workouts, I can see the distance by each swimming stroke style later in the Fitness app. However, if I build my own swim app, the distance by stroke style is not listed. What do I have to add, to have it listed there? The information are saved correct in the HKWorkoutEvent array in the workout.
Posted
by andre07.
Last updated
.
Post not yet marked as solved
2 Replies
548 Views
If I use the Apple training app on Apple Watch, indoor trainings like swimming in a pool will also store a location which I can see later in the Fitness app on the iPhone. My question: How do I store these location information with my own workout app on the watch? I tried creating a HKWorkoutRoute with the HKWorkoutRouteBuilder and added only one location. It saves fine, but the location does not appear in the Fitness app. If I query a workout recorded with the Apple training app on the iPhone, it also looks like there is no connected HKWorkoutRoute data stored. I also can not find any metadata key or something which I can use instead.
Posted
by andre07.
Last updated
.
Post not yet marked as solved
1 Replies
271 Views
May app is a health and wellness app giving tips on how to eat move and sleep better, fo weight loss and good health. Apple say that for the app to be accepted that it needs to include citations. However this is a little vague. For example a health app may include 100 different tips about working out; why strength training is better in some cases than cardio, why cardio can be good for mental health, how to sleep better, blue light blocking glasses, calorie deficit to lose weight etc. etc. etc. If you need say two citations for each bit of advice, that would be 200 citations. Looking at the other health apps out there, they don't include thorough citation or referencing. Does anybody know what level of citation apple is looking for? Or how I could see an example. I've looked at other apps, but none of them seem to include any 'easy to find' citations. Thanks in advance!
Posted Last updated
.
Post not yet marked as solved
0 Replies
268 Views
Point 27.4 of the App Store Review Guidelines reads: "Apps may not use or disclose to third parties user data gathered from the HealthKit or CareKit APIs or from health-related human subject research for advertising or other use-based data mining purposes other than improving health, or for the purpose of health research" Now, when the app will be ready for release I only intend to read the data and process it directly on the phone. However, for the purpose of testing I need to extract the data, get it on some excel / csv file and analize it. I initially thought to send the data to Firebase, but was told this might breach 27.4. I only intend to have this feature in the beta I'll release on Test Flight for myself, but still Apple might refuse it. What alternatives do I have? Can I save the data locally on my watch? Might be quite heavy (monitoring up to 8 hours) How do I get it to a computer then? Can I send the data to iCloud? I won't be developing the app first hand, I'm hiring someone so I need to understand what is feasable. Thank you for your help.
Posted
by MrMarch.
Last updated
.
Post not yet marked as solved
1 Replies
278 Views
Hello, With reference to HealthKit - Clinical Health Records, we implemented the following method to fetch the User's clinical records but seems the query is failing and the app is getting crashed every time. We tried the same method with Apple provided sample account and it works fine in the simulator, but it crashes with actual users Can you please help us to identify the issue? func getRecordsForCHRType(type: HKClinicalTypeIdentifier, completion:@escaping ([HKClinicalRecord]?) -> Void) { guard let healthRecordType = HKObjectType.clinicalType(forIdentifier: type) else { return } let startDate = Calendar.current.date(byAdding: DateComponents(day: -365), to: Date())! let endDate = Calendar.current.date(byAdding: DateComponents(day: 0), to: Date())! let predicate = HKQuery.predicateForSamples(withStart: startDate, end: endDate, options: [.strictStartDate]) let sortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: false) let healthRecordQuery = HKSampleQuery(sampleType: healthRecordType, predicate: predicate, limit: 0, sortDescriptors: [sortDescriptor]) { (query, samples, error) in guard let actualSamples = samples else { completion(nil) return } let healthRecordSamples = actualSamples as? [HKClinicalRecord] completion(healthRecordSamples) } HKHealthStore().execute(healthRecordQuery) } Additionally, please help us to understand the following different types of dates(in detail) available in sample Clinical Health Records JSON, and is it possible to apply a filter using any HealthKitQuery on these dates to narrow down the clinical records response? issued dateRecorded recordDate onset effective Any help would be appreciated!
Posted Last updated
.
Post not yet marked as solved
0 Replies
227 Views
I've ran into an error with the insertRouteData function of the HKWorkoutRouteBuilder that I can't seem to find any information on. The error is "Unable to find location series 1A193D3B-AFF5-41D8-A967-B1BE08D9F543 during data insert.". It seems to only happen when trying to insert very long routes, in the most recent case it was a 5 hour bike ride with 5900 samples. I save all the route data in a sqlite table as backup and after checking out the data there isn't any red flags as to why it would not insert correctly. Has anyone seen this before and could offer some insight or point me in the right direction to find the source of the error?
Posted
by Alex89.
Last updated
.
Post not yet marked as solved
1 Replies
1.5k Views
I am trying to sync my app with Apple's HealthKit.  When I initially set up my app, it gave an option to share data with the Health app.  I clicked "allow” for the read write permission. But now I have my app exporting blood pressure fine, but still my app is listed as 'inactive'! under the Data Sources. Is there a way to fix that? Deleting and reinstalling the app doesn't worked. Can anyone help me with more information?
Posted Last updated
.
Post marked as solved
1 Replies
341 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
0 Replies
193 Views
Hello, I bought a new iphone (13) and after the change I can see all my old activity, trends ect. but I don’t have any awards now. I lost all of them. How can I get them again?
Posted
by Somodi79.
Last updated
.
Post not yet marked as solved
0 Replies
231 Views
Hi, I'd like to create a gym app for apple watch. Is there any way to record the movements of the arms, so that apple watch knows when the movement has been made? Thanks Alberto
Posted Last updated
.
Post not yet marked as solved
2 Replies
306 Views
I have a problem when I want to send data through my appp from Apple Watch to server. When I restart it away from the iPhone. it wouldn't t send the the acquired data from the Apple Watch( heartbeats, location etc) to the server. it only send the data when it is paired to the phone. it is strange because the Apple Watch is still connected to wifi but wouldn't send to the server. it only send when it is paired
Posted
by dhiaapp.
Last updated
.
Post not yet marked as solved
1 Replies
602 Views
If a "Minimum Deployment Target" is updated to WatchOS7 on a product(iOS app with a companion watch app) that is already available on the App Store, watches running WatchOS6 will obviously no longer get updates. However, what is the experience for a user who has a WatchOS6 (maybe they own a Series 2) connected to an iPhone with iOS14? Will both the iPhone app and the Watch app stop getting updates? Will the Watch app stop getting updates, but the iPhone app continue receiving them and we have to manage this? Something else? Thanks in advance!
Posted Last updated
.
Post not yet marked as solved
1 Replies
568 Views
I'm trying to observe .irregularHeartRhythmEvent using HKObserverQuery. Code, I'm using to subscribe to this event: private func subscribeForAbnormals() { let abnormals = HKCategoryType.categoryType(forIdentifier: .irregularHeartRhythmEvent)! healthStore.enableBackgroundDelivery( for: abnormals, frequency: HKUpdateFrequency.immediate ) { isSuccess, error in let subscriptionStatus = isSuccess ? "OK ✅" : "FAILED ❌" print("Irregular hearbeat subscription status: \(subscriptionStatus)") if let error = error { print(error.localizedDescription) } } let query = HKObserverQuery( sampleType: abnormals, predicate: nil ) { [weak self] _, completionHandler, _ in print("Irregular hearbeat detected") completionHandler() } healthStore.execute(query) } Each time I call this function, I see output in my console: Irregular hearbeat subscription status: OK ✅ Irregular hearbeat detected According to HealthApp, I have no cases of Irregular Hearth Rhythm. Also, I havn't any options how to detect if triggered event is fake or not. Absolutely same situation with .lowHeartRateEvent and .highHeartRateEvent My app has all allowed accesses to HealthKit. How can I actually subscribe for such kind of events to track this and notify user?
Posted
by Pan_TERRA.
Last updated
.