I want to build a fitness app that will upload the data to HealthKit. Is there any way to open/navigate to HealthKit from another app?
Asked
Active
Viewed 5,934 times
3 Answers
20
On iOS 10, the Health app URL scheme is x-apple-health
. You can open it from within your own app by calling:
Objective-C:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"x-apple-health://"]];
Swift:
UIApplication.shared.open(URL(string: "x-apple-health://")!)
See Open Health app using url scheme | Apple Developer Forums.

Olivier
- 858
- 8
- 17
-
1Only work on iOS 10+. I don't think the Health app on iOS 8 or 9 has a registered URL schema. – bickster Dec 13 '16 at 20:54
-
@bickster You're right, it doesn't seem to work on iOS 8 or 9. I've updated my answer. Thanks! – Olivier Dec 14 '16 at 10:50
-
5Does anyone know how to open a special view? Like steps or weight? – patrickS Dec 28 '16 at 09:44
-
1This is not officially documented or supported, and could change at any time. I don't recommend you use this. – Allan May 16 '17 at 16:14
4
iOS does not provide a general API for launching other applications and the Health app would need to have support for URL scheme in order for you to launch it from your own application. See Launch an app from within another (iPhone).
3
Swift 5 "Safer way"
func openUrl(urlString: String) {
guard let url = URL(string: urlString) else {
return
}
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
Usage:
openUrl(urlString: "x-apple-health://")

Kevin Singh
- 421
- 8
- 14