This is the copy of source code one could see on What's new in Health Kit Session:
// predicate for sleep samples
let remSleepStagePredicate = HKCategoryValueSleepAnalysis.predicateForSamples(.equalTo, value: .asleepREM)
// create query with the designated sleepStagePredicate
let queryPredicate = HKSamplePredicate.sample(type: HKCategoryType(.sleepAnalysis), predicate: remSleepStagePredicate)
// Sleep Query
let sleepQuery = HKSampleQueryDescriptor(predicates: [queryPredicate], sortDescriptors: [])
// Run the query
let sleepSamples = try async sleepQuery.result(for: healthStore)
I tried to take a snaphot of the session itself, but for some reason I could not submit it with the file attached so I provided the code above.
I am wondering that shouldn't it be try await, not try async on the last line of the source code?
so the last line should be the code below:
let sleepSamples = try await sleepQuery.result(for: healthStore)
Am I mistaken, or is it a human error?
Post
Replies
Boosts
Views
Activity
https://developer.android.com/build/configure-app-module#set_the_application_id
In Android, you can separate a mobile app and a wearable app into different projects and still enable communication by setting the same applicationId in both project's build.gradle.kts files.
Thus, one may upload mobile app and wearable app into google store separately, and yet be able to receive/send messages with each other.
Is there a similar approach available for iOS and watchOS apps?
I tried separating the watchOS app into a new project and setting its WKCompanionAppBundleIdentifier to the original iOS app's Bundle Identifier.
But I'm still encountering errors as below:
WCSession counterpart app not installed
SessionIsNotReachable
Am I missing something, or is this approach not feasible on iOS/watchOS?
Also, if it is not feasible, I would like to know why such approach is available on Android, but not on iOS.
If it is feasible, correction for my approach, or introduction of a new approach would be greatly appreciated.