@kingstinct/react-native-healthkit 14.0.0 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.plugin.js +13 -7
- package/app.plugin.ts +18 -10
- package/ios/Helpers.swift +3 -6
- package/package.json +1 -1
package/app.plugin.js
CHANGED
|
@@ -53,20 +53,26 @@ const withEntitlementsPlugin = (
|
|
|
53
53
|
const withInfoPlistPlugin = (
|
|
54
54
|
config,
|
|
55
55
|
/**
|
|
56
|
-
* @type {{NSHealthShareUsageDescription
|
|
56
|
+
* @type {{NSHealthShareUsageDescription?: string | true, NSHealthUpdateUsageDescription?: string | false} | undefined}
|
|
57
57
|
* */
|
|
58
58
|
props,
|
|
59
59
|
) =>
|
|
60
60
|
withInfoPlist(config, (config) => {
|
|
61
61
|
config.modResults.NSHealthShareUsageDescription =
|
|
62
|
-
typeof props
|
|
62
|
+
typeof props?.NSHealthShareUsageDescription === 'string'
|
|
63
63
|
? props.NSHealthShareUsageDescription
|
|
64
|
-
:
|
|
64
|
+
: typeof config.modResults.NSHealthShareUsageDescription === 'string'
|
|
65
|
+
? config.modResults.NSHealthShareUsageDescription
|
|
66
|
+
: `${config.name} wants to read your health data`
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
if (props?.NSHealthUpdateUsageDescription !== false) {
|
|
69
|
+
config.modResults.NSHealthUpdateUsageDescription =
|
|
70
|
+
typeof props?.NSHealthUpdateUsageDescription === 'string'
|
|
71
|
+
? props.NSHealthUpdateUsageDescription
|
|
72
|
+
: typeof config.modResults.NSHealthUpdateUsageDescription === 'string'
|
|
73
|
+
? config.modResults.NSHealthUpdateUsageDescription
|
|
74
|
+
: `${config.name} wants to update your health data`
|
|
75
|
+
}
|
|
70
76
|
|
|
71
77
|
return config
|
|
72
78
|
})
|
package/app.plugin.ts
CHANGED
|
@@ -13,7 +13,7 @@ type BackgroundConfig = boolean
|
|
|
13
13
|
|
|
14
14
|
type InfoPlistConfig = {
|
|
15
15
|
NSHealthShareUsageDescription?: string | true
|
|
16
|
-
NSHealthUpdateUsageDescription?: string |
|
|
16
|
+
NSHealthUpdateUsageDescription?: string | false
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
type AppPluginConfig = InfoPlistConfig & {
|
|
@@ -40,17 +40,25 @@ const withEntitlementsPlugin: ConfigPlugin<{
|
|
|
40
40
|
|
|
41
41
|
const withInfoPlistPlugin: ConfigPlugin<InfoPlistConfig> = (config, props) => {
|
|
42
42
|
return withInfoPlist(config, (configPlist) => {
|
|
43
|
+
const existingShareDescription =
|
|
44
|
+
configPlist.modResults.NSHealthShareUsageDescription
|
|
43
45
|
configPlist.modResults.NSHealthShareUsageDescription =
|
|
44
|
-
typeof props
|
|
46
|
+
typeof props?.NSHealthShareUsageDescription === 'string'
|
|
45
47
|
? props.NSHealthShareUsageDescription
|
|
46
|
-
:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
: typeof existingShareDescription === 'string'
|
|
49
|
+
? existingShareDescription
|
|
50
|
+
: `${config.name ?? pkg.name} wants to read your health data`
|
|
51
|
+
|
|
52
|
+
if (props?.NSHealthUpdateUsageDescription !== false) {
|
|
53
|
+
const existingUpdateDescription =
|
|
54
|
+
configPlist.modResults.NSHealthUpdateUsageDescription
|
|
55
|
+
configPlist.modResults.NSHealthUpdateUsageDescription =
|
|
56
|
+
typeof props?.NSHealthUpdateUsageDescription === 'string'
|
|
57
|
+
? props.NSHealthUpdateUsageDescription
|
|
58
|
+
: typeof existingUpdateDescription === 'string'
|
|
59
|
+
? existingUpdateDescription
|
|
60
|
+
: `${config.name ?? pkg.name} wants to update your health data`
|
|
61
|
+
}
|
|
54
62
|
|
|
55
63
|
return configPlist
|
|
56
64
|
})
|
package/ios/Helpers.swift
CHANGED
|
@@ -86,14 +86,11 @@ func serializeAnchor(anchor: HKQueryAnchor?) -> String? {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
func toBase64(_ data: Any?) -> String? {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
let encoded = data.base64EncodedString()
|
|
92
|
-
|
|
93
|
-
return encoded
|
|
89
|
+
guard let archivedData = try? NSKeyedArchiver.archivedData(withRootObject: data, requiringSecureCoding: true) else {
|
|
90
|
+
return nil
|
|
94
91
|
}
|
|
95
92
|
|
|
96
|
-
return
|
|
93
|
+
return archivedData.base64EncodedString()
|
|
97
94
|
}
|
|
98
95
|
|
|
99
96
|
func sampleQueryAsync(
|