You can request access to the health kit from your watchOS application, but the user will need to accept the request on their iPhone. To do this, you request access to the health set of your watchOS application, as usual:
var healthKitTypesToRead = Set<HKObjectType>()
// TODO: add your read types here
var healthKitTypesToWrite = Set<HKSampleType>()
// TODO: add your write types here
healthStore.requestAuthorizationToShareTypes(healthKitTypesToWrite, readTypes: healthKitTypesToRead) { (success, error) -> Void in
// TODO: Handle success or failure
}
AppDelegate iOS:
func applicationShouldRequestHealthAuthorization(application: UIApplication) {
let healthStore = HKHealthStore()
healthStore.handleAuthorizationForExtensionWithCompletion { (success, error) -> Void in
}
}
, , , iPhone. iPhone, . iPhone, requestAuthorizationToShareTypes Apple.