HealthKit requestAuthorization(toShare:, read, completion: ) :有没有办法知道它是否至少被提示过一次?

HealthKit requestAuthorization(toShare:, read, completion: ) : is there are way to know whether it was promped at least once?

我目前正在使用 HealthKit,我想知道:是否有可能知道之前是否询问过 requestAuthorization?

根据文档,似乎不是。您可以询问特定 HKObjectType 的授权状态,但这只会告诉您是否可以 保存 该类型的数据。您无法判断是否已授予 read 访问权限。根据 docs:

To help prevent possible leaks of sensitive health information, your app cannot determine whether or not a user has granted permission to read data.

您可以调用 requestAuthorization repeatedly,只有当用户之前没有授予访问 HKObjectType 请求的权限时才会提示用户:

If the user has already chosen to grant or prohibit access to all of the types specified, the completion is called without prompting the user.