Health Kit 读取权限状态

Health Kit reading permission status

我正在开发一款与健康相关的应用程序。该应用程序的功能取决于健康和位置服务。我正在尝试访问健康数据权限(应用程序的某些部分将在没有健康数据权限的情况下受到限制)。我在互联网上搜索并阅读了苹果文档。我找到了一个函数

HKHealthStore().authorizationStatus(for: )

其中 returns 将数据保存到健康应用程序的状态,但这对我不起作用。我只需要阅读权限。我如何访问这些信息?

非常感谢任何帮助。 谢谢 :)

您无法确定您的应用程序是否具有读取访问权限。来自文档:

To help prevent possible leaks of sensitive health information, your app cannot determine whether or not a user has granted permission to read data. If you are not given permission, it simply appears as if there is no data of the requested type in the HealthKit store. If your app is given share permission but not read permission, you see only the data that your app has written to the store. Data from other sources remains hidden.