forked from agencyenterprise/react-native-health
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.plugin.js
49 lines (41 loc) · 1.51 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
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 withHealthKit = (
config,
{ healthSharePermission, healthUpdatePermission, isClinicalDataEnabled } = {},
) => {
// Add permissions
config = withInfoPlist(config, (config) => {
config.modResults.NSHealthShareUsageDescription =
healthSharePermission ||
config.modResults.NSHealthShareUsageDescription ||
HEALTH_SHARE
config.modResults.NSHealthUpdateUsageDescription =
healthUpdatePermission ||
config.modResults.NSHealthUpdateUsageDescription ||
HEALTH_UPDATE
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