Open HealthKit App from another app

后端 未结 3 1590
不知归路
不知归路 2020-12-31 04:31

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?

3条回答
  •  不知归路
    2020-12-31 05:20

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

提交回复
热议问题