我目前正在使用 HealthKit,我想知道:是否有可能知道 requestAuthorization 之前是否被问过?
1 回答
Based on the documentation, it appears not. You can ask for authorization status for a particular HKObjectType
, but this will only tell you if can save data of that type. You can't tell whether read access has been granted. According to the 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.
You can call requestAuthorization
repeatedly, and the user will only be prompted if they have not previously granted access to the HKObjectType
's requested:
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.