0

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.

KAREEM MAHAMMED
  • 1,675
  • 14
  • 38
  • I never did deep linking with other apple apps. However did you add an exception in the LSApplicationQueriesSchemes in your plist? – Croisciento Oct 13 '16 at 11:22
  • I **Hope,** This will helped you- [Launch app from other one](http://stackoverflow.com/questions/419119/launch-an-app-from-within-another-iphone) – iDeveloper Oct 13 '16 at 11:32
  • I added LSApplicationQueriesSchemes in info.plist. LSApplicationQueriesSchemes health – KAREEM MAHAMMED Oct 13 '16 at 11:32

3 Answers3

1

With iOS 10+ try this:

let mystr = "x-apple-health://"

Maybe in objective.c:

-(IBAction)openAppHealth:(id)sender {  
  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"x-apple-health://"] options:@{} completionHandler:nil];
}

with new openURL for iOS 10 openURL: deprecated in iOS 10

Joannes
  • 2,569
  • 3
  • 17
  • 39
0

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.

Yogesh Mv
  • 1,041
  • 1
  • 6
  • 12
0

I don't have any experience with the HealthKit framework but here's what I found :

According to Open Apple Health programmatically you cannot create a deeplink from your app to the Health app because it is not supported.

If you'd wish to use the Health app's data you'll have to implement the HealthKit framework into your app and asks for permission to your users.

I tried to deeplink into the Health app using code that works for other apps and got the same results as you.

Community
  • 1
  • 1
Croisciento
  • 149
  • 1
  • 12