仅读取Health Kit数据时删除应用程序时删除Health Kit Data

Delete Health Kit Data when deleting the app when only reading Health Kit data

我们正在制作一个只从 Health Kit 读取数据的应用程序。尽管我们只是阅读,但当我们将应用程序推送到 TestFlight 时,我们会收到一封电子邮件,说它缺少 NSHealthUpdateUsageDescription 键。我们只提供了 NSHealthShareUsageDescription 键,因为我们只是在读取数据。因此,我们现在被迫为 NSHealthUpdateUsageDescription 键提供与 NSHealthShareUsageDescription 相同的文本,即使它永远不会被使用。

此外,当我们删除应用程序时,iOS 会显示一条警告,询问用户是否要在尝试删除应用程序时删除 Health Kit 数据。

当我们只从 Health Kit 读取数据时,为什么我们会收到警报,为什么我们需要提供 NSHealthUpdateUsageDescription?

根据 official NSHealthUpdateUsageDescription documentation:

To protect user privacy, an iOS app linked on or after iOS 10.0, and that reads the user’s health data, must statically declare the intent to do so. Include the NSHealthUpdateUsageDescription key in your app’s Info.plist file and provide a purpose string for this key.

即使您并没有真正编写或更改 HealthKit 数据,您仍然在访问它。在某些地区(例如美国,我更强烈地怀疑在欧盟内部),健康隐私被认为是一项相对重要且法律要求的事情。因此,您应用的用户必须正式承认并允许您的应用读取 HealthKit 数据。

至于为什么您会看到有关数据可能被删除的警报,我怀疑 HealthKit API 写入了一小部分数据(例如标记您的应用程序被允许读取数据,或者记录读取的数据)