Open HealthKit App from another app

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.


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).


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://")

Tags:

Ios8

Healthkit