iphoneswiftxcodehealthkithkhealthstore

How to launch Health iOS app from another iOS APP


I am trying to launch Health app from my application.

I usually try with the following lines of code for launching application like as

 let mystr = "health://"
    let myurl = NSURL(string: mystr)!
    if (UIApplication.sharedApplication().canOpenURL(myurl))
    {
         UIApplication.sharedApplication().openURL(myurl)
    }
    else
    {
        print("unable to open")
    }

I tried above code.i am getting error ("null").

Some one please help in this issue.

Thanks in advance.


Solution

  • You cannot open HealthApp directly from your app. Because OS is supporting only for opening the settings App using UIApplicationOpenSettingsURLString. If we use URL scheme to open the HealthApp, then Apple may reject the App in review process.