Open Health Kit Permission Settings for the app that uses Health Kit

I am using Health Kit to display steps information for the user.

let healthKitTypes: Set = [ HKObjectType.quantityType(forIdentifier: HKQuantityTypeIdentifier.stepCount)!]

self.healthStore.requestAuthorization(toShare: healthKitTypes, read: healthKitTypes) { (bool, error) in
    
    if (bool) {
        // Auth granted
    } else {
        // Navigate user to HealthKit app permissions
    }
}

This code shows a popup to the user with the asked permissions. What I want to do in the // Navigate user to HealthKit app permissions is to open the Health Kit app permission settings directly for my app if the user did not approve the permissions on the popup.

I know that settings of the app can be opened by using something like this:

let settingsAction = UIAlertAction(title: "Settings", style: .default) { (_) -> Void in

    guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
        return
    }

    if UIApplication.shared.canOpenURL(settingsUrl) {
        UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
            print("Settings opened: (success)") // Prints true
        })
    }
}

… I want to do similar, just in this case open the Health Kit Setting permission screen so that users can enable the requested permissions directly in settings – if they decline them in the app popup.

Thanks

Source: Swift Questions