You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/PermissionsSwiftUIHealth/JMHealthPermissionManager.swift
+33-17Lines changed: 33 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,18 @@ import HealthKit
12
12
13
13
@available(iOS 13.0, tvOS 13.0,*)
14
14
publicextensionPermissionType.PermissionManager{
15
+
/**
16
+
Permission that allows app to access healthkit information
17
+
18
+
- Note: Extensive Info.plist values and configurations are required for HealthKit authorization. Please see Apple Developer [website](https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data) for details. \n
19
+
20
+
For example, passing in a `Set` of `HKSampleType`:
- Attention: From Apple Developer Documentation: "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."
@@ -33,46 +45,50 @@ public class JMHealthPermissionManager: PermissionType.PermissionManager {
33
45
init(categories:HKAccess){
34
46
self.categories = categories
35
47
}
48
+
49
+
/**
50
+
- Note: From Apple Developer Documentation: "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."
varallowDenyCount:CountComparison=(authorized:0, denied:0) //Tracks # of authorized and denied health categories
40
55
varstatus:AuthorizationStatus{
56
+
41
57
//Set to notDetermined if all permissions are not determined
42
58
if allowDenyCount.0==0 && allowDenyCount.1==0{
43
59
return.notDetermined
44
60
}
45
-
//Set to authorized if majority are authorized
46
-
if allowDenyCount.0> allowDenyCount.1{
61
+
62
+
//Set to authorized if at least 1 type is authorized
63
+
if allowDenyCount.0>0{
47
64
return.authorized
48
65
}
49
-
//Set to denied if majority are denied, or equal # of allowed and denied
50
-
return.denied
66
+
67
+
//If all types are denied, set status to denied
68
+
else{
69
+
return.denied
70
+
}
51
71
}
52
72
53
-
/**
54
-
- Note: From Apple Developer Documentation: "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."
55
-
*/
56
-
57
-
varreadPermissions= categories.readPermissions
58
-
varwritePermissions= categories.writePermissions
59
73
//Map the authorization status, remove allowed and denied permissions from array.
0 commit comments