简体   繁体   中英

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

我目前正在使用HealthKit,但我想知道:是否可以知道以前是否曾询问过requestAuthorization?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM