Post not yet marked as solved
Hey!
I would like to incorporate background delivery for my standalone Apple watch app by updating my Watch App Complication in a more timely manner compared to the scheduleBackgroundRefresh.
While the documentation states that the query should be executed in application(didFinishLaunchingWithOptions:), this wouldn't work in this case as the App might not be opened. So I register the background delivery whenever the Extension Delegate handle() is called with a WKApplicationRefreshBackgroundTask. However this only works whenever I debug the App on the Device... As soon as I stop debugging the App, the Complication is only updated through a scheduled Background Refresh.
I did enable the Background Delivery Capability & made sure that I didn't exceed the WKApplicationRefreshBackgroundTask budget — I'm currently testing on Beta 5.
Thanks a lot for any insights in advance!
Post not yet marked as solved
Hi evetyone! I from to Vietnam.
I have an Apple Watch SE. My watch was working fine before but a week now the sharing feature works, the competition with everyone on Apple Watch has not worked (playing with everyone wins or loses still does not receive a badge) completed the challenge, can't see the scores everyone has competed,...), but the three fitness circles on my watch are still working properly. I have disconnected the watch from my iPhone and then reconnecting it still does not fix the error, I also sent feedback on August 16, but as of today August 22 I still have not received a response from Apple, I do not know if my feedback reaches Apple?
I really hope Apple reads this and responds to me. Thanks very much!
Post not yet marked as solved
Install app on phone and watch
Power the watch off
Run the app on the phone.
WCSession.default.isWatchAppInstalled == true
WCSession.isSupported() == true
WCSession.default.isPaired == true
WCSession.default.activationState == .activated
Now I try to run HKHealthStore startWatchApp.
The startWatchApp method's completion never fires.
I'd like to detect that the watch is powered off, so then I do not try to run the startWatchApp method. I can't see a way to detect that the watch is powered off.
Alternatively - I'd like startWatchApp to quickly fail, or - to have some way of cancelling it if it doesn't return quickly.
Any ideas please?
Post not yet marked as solved
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
Post marked as Apple Recommended
Is it possible to update the UI of an application written in WatchKit (not SwiftUI) while the watch is lowered and the device is in always-on mode?
I am wanting to continue to update a WKInterfaceTimer label (which shows minutes and seconds) and a couple of WKInterfaceLabel which show live HealthKit info for a fitness app.
I can't seem to see any Watchkit APIs for this and if I do not pause a WKInterfaceTimer when the didDeactivate is called on a WKInterfaceController the it still seems to pause when the app is put into always on mode.
Post not yet marked as solved
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.
Post not yet marked as solved
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
Post not yet marked as solved
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.
Post not yet marked as solved
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?
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?
Post not yet marked as solved
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?
Post not yet marked as solved
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!
Post not yet marked as solved
Hi,
I am a first time iOS developer, are there any regulations around what I need to develop on Apples HealthKit and use heart rate data in my app other than a privacy certificate and asking user permission?
Kind regards,
n00b
Post not yet marked as solved
Hello,
I am working on a healthcare app and want to integrate speech to text functionality in app. Before that, I wanted to make sure that the framework 'Speech', provided by Apple is HIPAA complaint. Please help me to know this.
Post not yet marked as solved
So the documentation here only says:
A quantity sample type that measures the standard deviation of heartbeat intervals.
And below:
Discussion
These samples use time units (described in HKUnit) and measure discrete values (described in HKStatisticsQuery).
HealthKit calculates the Heart rate variability (HRV) by measuring the variation between individual heartbeats. While there are multiple ways of computing HRV, HealthKit uses SDNN heart rate variability, which uses the standard deviation of the inter-beat (RR) intervals between normal heartbeats (typically measured in milliseconds).
There is no details on how many heartbeat intervals are used to calculate the SDNN and how to modify it.
What if I want to calculate the SDNN on the last 30 intervals? Or the last 10? or the last 100? Or maybe I just want to calculate it on a timeframe, like 60 seconds, regardless of there were 50 or 120 heartbeats.
Post not yet marked as solved
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!
Post not yet marked as solved
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.
Post not yet marked as solved
I can able to get my health data list from health kit. I used below code to get my today's step count :
`func getTodaysSteps(completion: @escaping (Double) -> Void) {
let stepsQuantityType = HKQuantityType.quantityType(forIdentifier: .stepCount)!
let now = Date()
let startOfDay = Calendar.current.startOfDay(for: now)
let predicate = HKQuery.predicateForSamples(
withStart: startOfDay,
end: now,
options: .strictStartDate
)
let query = HKStatisticsQuery(
quantityType: stepsQuantityType,
quantitySamplePredicate: predicate,
options: .cumulativeSum
) { _, result, _ in
guard let result = result, let sum = result.sumQuantity() else {
completion(0.0)
return
}
completion(sum.doubleValue(for: HKUnit.count()))
}
healthStore.execute(query)
}`
But i have one more health data of my brother, where he invited me to see his health data in my real device. Now i was not able to read / get his health data. Is there any way to get that.
Any solution would be great ...!
Hello,
I am wondering whether a 3rd party application (which i wish to develop) can request information, such as heart rate, from the apple watch. I wish for my app to have heart rate, as an input. Is this possible?
kind regards
Post not yet marked as solved
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: