-
Notifications
You must be signed in to change notification settings - Fork 235
/
app.plugin.js
56 lines (48 loc) · 1.87 KB
/
app.plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const { withEntitlementsPlist, withInfoPlist } = require('@expo/config-plugins')
const HEALTH_SHARE = 'Allow $(PRODUCT_NAME) to check health info'
const HEALTH_UPDATE = 'Allow $(PRODUCT_NAME) to update health info'
const HEALTH_CLINIC_SHARE = 'Allow $(PRODUCT_NAME) to check health clinical info'
const withHealthKit = (
config,
{ healthSharePermission, healthUpdatePermission, isClinicalDataEnabled, healthClinicalDescription } = {},
) => {
// Add permissions
config = withInfoPlist(config, (config) => {
config.modResults.NSHealthShareUsageDescription =
healthSharePermission ||
config.modResults.NSHealthShareUsageDescription ||
HEALTH_SHARE
config.modResults.NSHealthUpdateUsageDescription =
healthUpdatePermission ||
config.modResults.NSHealthUpdateUsageDescription ||
HEALTH_UPDATE
isClinicalDataEnabled ?
config.modResults.NSHealthClinicalHealthRecordsShareUsageDescription =
healthClinicalDescription ||
config.modResults.NSHealthClinicalHealthRecordsShareUsageDescription ||
HEALTH_CLINIC_SHARE :
null
return config
})
// Add entitlements. These are automatically synced when using EAS build for production apps.
config = withEntitlementsPlist(config, (config) => {
config.modResults['com.apple.developer.healthkit'] = true
if (
!Array.isArray(config.modResults['com.apple.developer.healthkit.access'])
) {
config.modResults['com.apple.developer.healthkit.access'] = []
}
if (isClinicalDataEnabled) {
config.modResults['com.apple.developer.healthkit.access'].push(
'health-records',
)
// Remove duplicates
config.modResults['com.apple.developer.healthkit.access'] = [
...new Set(config.modResults['com.apple.developer.healthkit.access']),
]
}
return config
})
return config
}
module.exports = withHealthKit