@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 CHANGED
@@ -53,20 +53,26 @@ const withEntitlementsPlugin = (
53
53
  const withInfoPlistPlugin = (
54
54
  config,
55
55
  /**
56
- * @type {{NSHealthShareUsageDescription: string | true, NSHealthUpdateUsageDescription: string | true} | undefined}
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.NSHealthShareUsageDescription === 'string'
62
+ typeof props?.NSHealthShareUsageDescription === 'string'
63
63
  ? props.NSHealthShareUsageDescription
64
- : `${config.name} wants to read your health data`
64
+ : typeof config.modResults.NSHealthShareUsageDescription === 'string'
65
+ ? config.modResults.NSHealthShareUsageDescription
66
+ : `${config.name} wants to read your health data`
65
67
 
66
- config.modResults.NSHealthUpdateUsageDescription =
67
- typeof props.NSHealthUpdateUsageDescription === 'string'
68
- ? props.NSHealthUpdateUsageDescription
69
- : `${config.name} wants to update your health data`
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 | true
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.NSHealthShareUsageDescription === 'string'
46
+ typeof props?.NSHealthShareUsageDescription === 'string'
45
47
  ? props.NSHealthShareUsageDescription
46
- : `${config.name ?? pkg.name} wants to read your health data`
47
-
48
- // Add description if it's not undefined and not explicitly false
49
-
50
- configPlist.modResults.NSHealthUpdateUsageDescription =
51
- typeof props.NSHealthUpdateUsageDescription === 'string'
52
- ? props.NSHealthUpdateUsageDescription
53
- : `${config.name ?? pkg.name} wants to update your health data`
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
- if let data = data {
90
- let data = NSKeyedArchiver.archivedData(withRootObject: data)
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 nil
93
+ return archivedData.base64EncodedString()
97
94
  }
98
95
 
99
96
  func sampleQueryAsync(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingstinct/react-native-healthkit",
3
- "version": "14.0.0",
3
+ "version": "14.0.2",
4
4
  "description": "React Native bindings for HealthKit",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",