@tryvital/vital-health-react-native 3.0.10 → 3.1.0-beta.1

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.
Files changed (134) hide show
  1. package/android/build/.transforms/56bdc14fef9e29e3b063d932e1530458/transformed/classes/classes_dex/classes.dex +0 -0
  2. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/AskForPermissionContinuation.dex +0 -0
  3. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/EnableBackgroundSyncContinuation.dex +0 -0
  4. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$Companion.dex +0 -0
  5. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$$inlined$runOnMain$1.dex +0 -0
  6. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$1$launcher$1$1.dex +0 -0
  7. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$1$launcher$1.dex +0 -0
  8. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$configure$$inlined$runOnMain$1.dex +0 -0
  9. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$disableBackgroundSync$$inlined$runOnMain$1.dex +0 -0
  10. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$$inlined$runOnMain$1.dex +0 -0
  11. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$1$launcher$1$1.dex +0 -0
  12. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$1$launcher$1.dex +0 -0
  13. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$getPauseSynchronization$$inlined$runOnMain$1.dex +0 -0
  14. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$hasAskedForPermission$$inlined$runOnMain$1.dex +0 -0
  15. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$isAvailable$$inlined$runOnMain$1.dex +0 -0
  16. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$isBackgroundSyncEnabled$$inlined$runOnMain$1.dex +0 -0
  17. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$runOnMain$1.dex +0 -0
  18. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$setPauseSynchronization$$inlined$runOnMain$1.dex +0 -0
  19. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$setSyncNotificationContent$$inlined$runOnMain$1.dex +0 -0
  20. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$startStatusUpdate$1.dex +0 -0
  21. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$syncData$$inlined$runOnMain$1.dex +0 -0
  22. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$vitalCore$2.dex +0 -0
  23. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$writeHealthData$$inlined$runOnMain$1.dex +0 -0
  24. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule.dex +0 -0
  25. package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
  26. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/AskForPermissionContinuation.class +0 -0
  27. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/EnableBackgroundSyncContinuation.class +0 -0
  28. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$Companion.class +0 -0
  29. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$$inlined$runOnMain$1.class +0 -0
  30. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$1$launcher$1$1.class +0 -0
  31. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$1$launcher$1.class +0 -0
  32. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$configure$$inlined$runOnMain$1.class +0 -0
  33. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$disableBackgroundSync$$inlined$runOnMain$1.class +0 -0
  34. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$$inlined$runOnMain$1.class +0 -0
  35. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$1$launcher$1$1.class +0 -0
  36. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$1$launcher$1.class +0 -0
  37. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$getPauseSynchronization$$inlined$runOnMain$1.class +0 -0
  38. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$hasAskedForPermission$$inlined$runOnMain$1.class +0 -0
  39. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$isAvailable$$inlined$runOnMain$1.class +0 -0
  40. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$isBackgroundSyncEnabled$$inlined$runOnMain$1.class +0 -0
  41. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$runOnMain$1.class +0 -0
  42. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$setPauseSynchronization$$inlined$runOnMain$1.class +0 -0
  43. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$setSyncNotificationContent$$inlined$runOnMain$1.class +0 -0
  44. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$startStatusUpdate$1.class +0 -0
  45. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$syncData$$inlined$runOnMain$1.class +0 -0
  46. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$vitalCore$2.class +0 -0
  47. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$writeHealthData$$inlined$runOnMain$1.class +0 -0
  48. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule.class +0 -0
  49. package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
  50. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  51. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  52. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  53. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  54. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  55. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
  56. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
  57. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  58. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  59. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  60. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  61. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  62. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  63. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  64. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
  65. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  66. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  67. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  68. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  69. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  70. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  71. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  72. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  73. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  74. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  75. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  76. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  77. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  78. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  79. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  80. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  81. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  82. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  83. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  84. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  85. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  86. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  87. package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
  88. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/AskForPermissionContinuation.class +0 -0
  89. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/EnableBackgroundSyncContinuation.class +0 -0
  90. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$Companion.class +0 -0
  91. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$$inlined$runOnMain$1.class +0 -0
  92. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$1$launcher$1$1.class +0 -0
  93. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$1$launcher$1.class +0 -0
  94. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$configure$$inlined$runOnMain$1.class +0 -0
  95. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$disableBackgroundSync$$inlined$runOnMain$1.class +0 -0
  96. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$$inlined$runOnMain$1.class +0 -0
  97. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$1$launcher$1$1.class +0 -0
  98. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$1$launcher$1.class +0 -0
  99. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$getPauseSynchronization$$inlined$runOnMain$1.class +0 -0
  100. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$hasAskedForPermission$$inlined$runOnMain$1.class +0 -0
  101. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$isAvailable$$inlined$runOnMain$1.class +0 -0
  102. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$isBackgroundSyncEnabled$$inlined$runOnMain$1.class +0 -0
  103. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$runOnMain$1.class +0 -0
  104. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$setPauseSynchronization$$inlined$runOnMain$1.class +0 -0
  105. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$setSyncNotificationContent$$inlined$runOnMain$1.class +0 -0
  106. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$startStatusUpdate$1.class +0 -0
  107. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$syncData$$inlined$runOnMain$1.class +0 -0
  108. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$vitalCore$2.class +0 -0
  109. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$writeHealthData$$inlined$runOnMain$1.class +0 -0
  110. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule.class +0 -0
  111. package/android/build.gradle +1 -1
  112. package/android/src/main/java/com/vitalhealthreactnative/VitalHealthReactNativeModule.kt +168 -52
  113. package/ios/VitalHealthReactNative.m +7 -0
  114. package/ios/VitalHealthReactNative.swift +12 -0
  115. package/lib/commonjs/index.js +120 -0
  116. package/lib/commonjs/index.js.map +1 -1
  117. package/lib/module/index.js +120 -0
  118. package/lib/module/index.js.map +1 -1
  119. package/lib/typescript/index.d.ts +88 -0
  120. package/lib/typescript/index.d.ts.map +1 -1
  121. package/package.json +1 -1
  122. package/src/index.tsx +134 -0
  123. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$launcher$1$1.dex +0 -0
  124. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$configure$1.dex +0 -0
  125. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$syncData$1.dex +0 -0
  126. package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$writeHealthData$1.dex +0 -0
  127. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$launcher$1$1.class +0 -0
  128. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$configure$1.class +0 -0
  129. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$syncData$1.class +0 -0
  130. package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$writeHealthData$1.class +0 -0
  131. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$launcher$1$1.class +0 -0
  132. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$configure$1.class +0 -0
  133. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$syncData$1.class +0 -0
  134. package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$writeHealthData$1.class +0 -0
@@ -18,6 +18,32 @@ export const VitalHealthEvents = {
18
18
  };
19
19
  export class VitalHealth {
20
20
  static status = new NativeEventEmitter(VitalHealthReactNative);
21
+ static get canEnableBackgroundSyncNoninteractively() {
22
+ return Platform.OS !== 'android';
23
+ }
24
+
25
+ /**
26
+ * Whether health data sync is paused at the moment.
27
+ */
28
+ static get pauseSynchronization() {
29
+ return VitalHealthReactNative.getPauseSynchronization();
30
+ }
31
+
32
+ /**
33
+ * [Android ONLY][Experimental API]
34
+ * On iOS, this property always returns `true`. iOS HealthKit Background Delivery is
35
+ * an app-level entitlement, and does not require explicit user consent.
36
+ *
37
+ * ## Overview
38
+ *
39
+ * Whether Background Sync on Android is enabled at the moment.
40
+ */
41
+ static get isBackgroundSyncEnabled() {
42
+ if (Platform.OS !== 'android') {
43
+ return Promise.resolve(true);
44
+ }
45
+ return VitalHealthReactNative.isBackgroundSyncEnabled();
46
+ }
21
47
  static isAvailable() {
22
48
  if (Platform.OS === 'android') {
23
49
  return VitalHealthReactNative.isAvailable();
@@ -38,6 +64,100 @@ export class VitalHealth {
38
64
  static configureClient(apiKey, environment, region, enableLogs) {
39
65
  return VitalHealthReactNative.configureClient(apiKey, environment, region, enableLogs);
40
66
  }
67
+
68
+ /**
69
+ * [Android ONLY][Experimental API]
70
+ * On iOS, this method is a no-op returning `true`. iOS HealthKit Background Delivery is an app-level
71
+ * entitlement, and does not require explicit user consent.
72
+ *
73
+ * If you intend to pause or unpause synchronization, use `pauseSynchronization`
74
+ * and `setPauseSynchronization(_:)` instead.
75
+ *
76
+ * ## Overview
77
+ *
78
+ * Enable background sync on Android. This includes requesting permissions from the end user whenever necessary.
79
+ *
80
+ * Vital SDK achieves automatic data sync through Android [AlarmManager] exact alarms.
81
+ *
82
+ * Refer to the [Vital Health Connect guide for full context and setup instructions](https://docs.tryvital.io/wearables/guides/android_health_connect).
83
+ *
84
+ * ## Gist on Exact Alarms
85
+ *
86
+ * "Exact Alarm" here refers to the Android Exact Alarm mechanism. The Vital SDK would propose
87
+ * to the Android OS to fire the next data sync with a T+60min wall clock target. The Android OS
88
+ * may fulfill the request exactly as proposed, e.g., when the user happens to be actively using
89
+ * the device. However, it may also choose to defer it arbitrarily, under the influence of
90
+ * power-saving policies like [Doze mode](https://developer.android.com/training/monitoring-device-state/doze-standby#understand_doze).
91
+ *
92
+ * On Android 12 (API Level 31) or above, this contract would automatically initiate the OS-required
93
+ * user consent flow for Exact Alarm usage. If the permission has been granted prior, this activity
94
+ * contract shall return synchronously.
95
+ *
96
+ * On Android 13 (API Level 33) or above, you have the option to use (with platform policy caveats)
97
+ * the [android.Manifest.permission.USE_EXACT_ALARM] permission instead, which does not require an
98
+ * explicit consent flow. This contract would return synchronously in this scenario.
99
+ *
100
+ * Regardless of API Level, your App Manifest must declare [android.Manifest.permission.RECEIVE_BOOT_COMPLETED].
101
+ * Otherwise, background sync stops once the phone encounters a cold reboot or a quick restart.
102
+ *
103
+ * @return `true` if the background sync has been enabled successfully. `false` otherwise.
104
+ */
105
+ static async enableBackgroundSync() {
106
+ if (Platform.OS !== "android") {
107
+ // iOS background delivery does not require user explicit consent.
108
+ // It requires only the app-level HealthKit Bgnd. Delivery entitlement.
109
+ return true;
110
+ }
111
+ return await VitalHealthReactNative.enableBackgroundSync();
112
+ }
113
+
114
+ /**
115
+ * [Android ONLY][Experimental API]
116
+ * On iOS, this method is a no-op. iOS HealthKit Background Delivery is an app-level
117
+ * entitlement, and does not require explicit user consent.
118
+ *
119
+ * If you intend to pause or unpause synchronization, use `pauseSynchronization`
120
+ * and `setPauseSynchronization(_:)` instead.
121
+ *
122
+ * ## Overview
123
+ *
124
+ * Disable background sync on Android.
125
+ */
126
+ static async disableBackgroundSync() {
127
+ if (Platform.OS !== "android") {
128
+ // iOS background delivery does not require user explicit consent.
129
+ // It requires only the app-level HealthKit Bgnd. Delivery entitlement.
130
+ return;
131
+ }
132
+ return await VitalHealthReactNative.disableBackgroundSync();
133
+ }
134
+
135
+ /**
136
+ * [Android ONLY][Experimental API]
137
+ * On iOS, this method is a no-op. iOS does not require apps to show a user-visible
138
+ * notification when performing extended work in background.
139
+ *
140
+ * ## Overview
141
+ * Set the text content related to the Sync Notification. The OS has full discretion to present
142
+ * this notification to the user, when any data sync work in background is taking longer than expected.
143
+ *
144
+ * Refer to the [Vital Health Connect guide for full context and setup instructions](https://docs.tryvital.io/wearables/guides/android_health_connect).
145
+ */
146
+ static async setSyncNotificationContent(content) {
147
+ if (Platform.OS !== "android") {
148
+ // iOS background delivery does not require user explicit consent.
149
+ // It requires only the app-level HealthKit Bgnd. Delivery entitlement.
150
+ return;
151
+ }
152
+ return await VitalHealthReactNative.setSyncNotificationContent(JSON.stringify(content));
153
+ }
154
+
155
+ /**
156
+ * Pause or unpause health data sync.
157
+ */
158
+ static async setPauseSynchronization(paused) {
159
+ return await VitalHealthReactNative.setPauseSynchronization(paused);
160
+ }
41
161
  static askForResources(resources) {
42
162
  return VitalHealthReactNative.ask(resources, []);
43
163
  }
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","NativeModules","Platform","VitalCore","LINKING_ERROR","select","ios","default","VitalHealthReactNative","Proxy","get","Error","VitalHealthReactNativeModule","VitalHealthEvents","statusEvent","VitalHealth","status","isAvailable","OS","Promise","resolve","configure","healthConfig","androidConfig","syncOnAppStart","numberOfDaysToBackFill","logsEnabled","iOSConfig","backgroundDeliveryEnabled","setUserId","userId","configureClient","apiKey","environment","region","enableLogs","askForResources","resources","ask","readResources","writeResources","writeHealthData","resource","value","startDate","endDate","getTime","hasAskedForPermission","syncData","cleanUp","signOut","VitalResource","VitalWriteResource"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAE1E,SAASC,SAAS,QAAQ,mCAAmC;;AAE7D;AACA,cAAc,iBAAiB;AAE/B,MAAMC,aAAa,GAChB,oFAAmF,GACpFF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,sBAAsB,GAAGP,aAAa,CAACO,sBAAsB,GAC/DP,aAAa,CAACO,sBAAsB,GACpC,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,OAAO,MAAMQ,4BAA4B,GAAGJ,sBAAsB;AAElE,OAAO,MAAMK,iBAAiB,GAAG;EAC/BC,WAAW,EAAE;AACf,CAAC;AAED,OAAO,MAAMC,WAAW,CAAC;EACvB,OAAOC,MAAM,GAAG,IAAIhB,kBAAkB,CAACQ,sBAAsB,CAAC;EAE9D,OAAOS,WAAWA,CAAA,EAAqB;IACrC,IAAIf,QAAQ,CAACgB,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOV,sBAAsB,CAACS,WAAW,CAAC,CAAC;IAC7C,CAAC,MAAM;MACL,OAAOE,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;IAC9B;EACF;EAEA,OAAOC,SAASA,CAACC,YAA0B,EAAiB;IAC1D,IAAIpB,QAAQ,CAACgB,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOV,sBAAsB,CAACa,SAAS,CACrCC,YAAY,CAACC,aAAa,CAACC,cAAc,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kB;IAC9B,OAAO9C,SAAS,CAAC+C,OAAO,CAAC,CAAC;EAC5B;AACF;;AAEA;AACA,WAAYC,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAiBzB,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA,OAGO"}
1
+ {"version":3,"names":["NativeEventEmitter","NativeModules","Platform","VitalCore","LINKING_ERROR","select","ios","default","VitalHealthReactNative","Proxy","get","Error","VitalHealthReactNativeModule","VitalHealthEvents","statusEvent","VitalHealth","status","canEnableBackgroundSyncNoninteractively","OS","pauseSynchronization","getPauseSynchronization","isBackgroundSyncEnabled","Promise","resolve","isAvailable","configure","healthConfig","androidConfig","syncOnAppStart","numberOfDaysToBackFill","logsEnabled","iOSConfig","backgroundDeliveryEnabled","setUserId","userId","configureClient","apiKey","environment","region","enableLogs","enableBackgroundSync","disableBackgroundSync","setSyncNotificationContent","content","JSON","stringify","setPauseSynchronization","paused","askForResources","resources","ask","readResources","writeResources","writeHealthData","resource","value","startDate","endDate","getTime","hasAskedForPermission","syncData","cleanUp","signOut","VitalResource","VitalWriteResource"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAE1E,SAASC,SAAS,QAAQ,mCAAmC;;AAE7D;AACA,cAAc,iBAAiB;AAE/B,MAAMC,aAAa,GAChB,oFAAmF,GACpFF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC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,CACrCC,YAAY,CAACC,aAAa,CAACC,cAAc,EACzCF,YAAY,CAACG,sBAAsB,EACnCH,YAAY,CAACI,WACf,CAAC;IACH,CAAC,MAAM;MACL,OAAOtB,sBAAsB,CAACiB,SAAS,CACrCC,YAAY,CAACK,SAAS,CAACC,yBAAyB,EAChDN,YAAY,CAACG,sBAAsB,EACnCH,YAAY,CAACI,WACf,CAAC;IACH;EACF;EAEA,OAAOG,SAASA,CAACC,MAAc,EAAiB;IAC9C,OAAO1B,sBAAsB,CAACyB,SAAS,CAACC,MAAM,CAAC;EACjD;EAEA,OAAOC,eAAeA,CACpBC,MAAc,EACdC,WAAmB,EACnBC,MAAc,EACdC,UAAmB,EACJ;IACf,OAAO/B,sBAAsB,CAAC2B,eAAe,CAC3CC,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,UACF,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaC,oBAAoBA,CAAA,EAAqB;IACpD,IAAItC,QAAQ,CAACgB,EAAE,KAAK,SAAS,EAAE;MAC7B;MACA;MACA,OAAO,IAAI;IACb;IAEA,OAAO,MAAMV,sBAAsB,CAACgC,oBAAoB,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaC,qBAAqBA,CAAA,EAAkB;IAClD,IAAIvC,QAAQ,CAACgB,EAAE,KAAK,SAAS,EAAE;MAC7B;MACA;MACA;IACF;IAEA,OAAO,MAAMV,sBAAsB,CAACiC,qBAAqB,CAAC,CAAC;EAC7D;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaC,0BAA0BA,CAACC,OAAgC,EAAiB;IACvF,IA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AbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAiBzB,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA,OAGO"}
@@ -5,12 +5,100 @@ export declare const VitalHealthReactNativeModule: any;
5
5
  export declare const VitalHealthEvents: {
6
6
  statusEvent: string;
7
7
  };
8
+ export interface SyncNotificationContent {
9
+ notificationTitle: string;
10
+ notificationContent: string;
11
+ channelName: string;
12
+ channelDescription: string;
13
+ }
8
14
  export declare class VitalHealth {
9
15
  static status: NativeEventEmitter;
16
+ static get canEnableBackgroundSyncNoninteractively(): boolean;
17
+ /**
18
+ * Whether health data sync is paused at the moment.
19
+ */
20
+ static get pauseSynchronization(): Promise<boolean>;
21
+ /**
22
+ * [Android ONLY][Experimental API]
23
+ * On iOS, this property always returns `true`. iOS HealthKit Background Delivery is
24
+ * an app-level entitlement, and does not require explicit user consent.
25
+ *
26
+ * ## Overview
27
+ *
28
+ * Whether Background Sync on Android is enabled at the moment.
29
+ */
30
+ static get isBackgroundSyncEnabled(): Promise<boolean>;
10
31
  static isAvailable(): Promise<boolean>;
11
32
  static configure(healthConfig: HealthConfig): Promise<void>;
12
33
  static setUserId(userId: string): Promise<void>;
13
34
  static configureClient(apiKey: string, environment: string, region: string, enableLogs: boolean): Promise<void>;
35
+ /**
36
+ * [Android ONLY][Experimental API]
37
+ * On iOS, this method is a no-op returning `true`. iOS HealthKit Background Delivery is an app-level
38
+ * entitlement, and does not require explicit user consent.
39
+ *
40
+ * If you intend to pause or unpause synchronization, use `pauseSynchronization`
41
+ * and `setPauseSynchronization(_:)` instead.
42
+ *
43
+ * ## Overview
44
+ *
45
+ * Enable background sync on Android. This includes requesting permissions from the end user whenever necessary.
46
+ *
47
+ * Vital SDK achieves automatic data sync through Android [AlarmManager] exact alarms.
48
+ *
49
+ * Refer to the [Vital Health Connect guide for full context and setup instructions](https://docs.tryvital.io/wearables/guides/android_health_connect).
50
+ *
51
+ * ## Gist on Exact Alarms
52
+ *
53
+ * "Exact Alarm" here refers to the Android Exact Alarm mechanism. The Vital SDK would propose
54
+ * to the Android OS to fire the next data sync with a T+60min wall clock target. The Android OS
55
+ * may fulfill the request exactly as proposed, e.g., when the user happens to be actively using
56
+ * the device. However, it may also choose to defer it arbitrarily, under the influence of
57
+ * power-saving policies like [Doze mode](https://developer.android.com/training/monitoring-device-state/doze-standby#understand_doze).
58
+ *
59
+ * On Android 12 (API Level 31) or above, this contract would automatically initiate the OS-required
60
+ * user consent flow for Exact Alarm usage. If the permission has been granted prior, this activity
61
+ * contract shall return synchronously.
62
+ *
63
+ * On Android 13 (API Level 33) or above, you have the option to use (with platform policy caveats)
64
+ * the [android.Manifest.permission.USE_EXACT_ALARM] permission instead, which does not require an
65
+ * explicit consent flow. This contract would return synchronously in this scenario.
66
+ *
67
+ * Regardless of API Level, your App Manifest must declare [android.Manifest.permission.RECEIVE_BOOT_COMPLETED].
68
+ * Otherwise, background sync stops once the phone encounters a cold reboot or a quick restart.
69
+ *
70
+ * @return `true` if the background sync has been enabled successfully. `false` otherwise.
71
+ */
72
+ static enableBackgroundSync(): Promise<boolean>;
73
+ /**
74
+ * [Android ONLY][Experimental API]
75
+ * On iOS, this method is a no-op. iOS HealthKit Background Delivery is an app-level
76
+ * entitlement, and does not require explicit user consent.
77
+ *
78
+ * If you intend to pause or unpause synchronization, use `pauseSynchronization`
79
+ * and `setPauseSynchronization(_:)` instead.
80
+ *
81
+ * ## Overview
82
+ *
83
+ * Disable background sync on Android.
84
+ */
85
+ static disableBackgroundSync(): Promise<void>;
86
+ /**
87
+ * [Android ONLY][Experimental API]
88
+ * On iOS, this method is a no-op. iOS does not require apps to show a user-visible
89
+ * notification when performing extended work in background.
90
+ *
91
+ * ## Overview
92
+ * Set the text content related to the Sync Notification. The OS has full discretion to present
93
+ * this notification to the user, when any data sync work in background is taking longer than expected.
94
+ *
95
+ * Refer to the [Vital Health Connect guide for full context and setup instructions](https://docs.tryvital.io/wearables/guides/android_health_connect).
96
+ */
97
+ static setSyncNotificationContent(content: SyncNotificationContent): Promise<void>;
98
+ /**
99
+ * Pause or unpause health data sync.
100
+ */
101
+ static setPauseSynchronization(paused: boolean): Promise<any>;
14
102
  static askForResources(resources: VitalResource[]): Promise<void>;
15
103
  static ask(readResources: VitalResource[], writeResources: VitalWriteResource[]): Promise<void>;
16
104
  static writeHealthData(resource: VitalWriteResource, value: number, startDate: Date, endDate: Date): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA2B,MAAM,cAAc,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIpD,cAAc,iBAAiB,CAAC;AAmBhC,eAAO,MAAM,4BAA4B,KAAyB,CAAC;AAEnE,eAAO,MAAM,iBAAiB;;CAE7B,CAAC;AAEF,qBAAa,WAAW;IACtB,MAAM,CAAC,MAAM,qBAAkD;IAE/D,MAAM,CAAC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAQtC,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB3D,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,MAAM,CAAC,eAAe,CACpB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,IAAI,CAAC;IAShB,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjE,MAAM,CAAC,GAAG,CACR,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C,eAAe,CACpB,QAAQ,EAAE,kBAAkB,EAC5B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,IAAI,GACZ,OAAO,CAAC,IAAI,CAAC;IAShB,MAAM,CAAC,qBAAqB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvE,MAAM,CAAC,QAAQ,CAAC,SAAS,GAAE,aAAa,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/D;;;OAGG;IACH,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC;AAGD,oBAAY,aAAa;IACvB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,cAAc,mBAAmB;CAClC;AAED,oBAAY,kBAAkB;IAC5B,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,cAAc,mBAAmB;CAClC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvital/vital-health-react-native",
3
- "version": "3.0.10",
3
+ "version": "3.1.0-beta.1",
4
4
  "description": "Client to access iOS's HealthKit and Android HealthConnect",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
package/src/index.tsx CHANGED
@@ -28,9 +28,44 @@ export const VitalHealthEvents = {
28
28
  statusEvent: 'Status',
29
29
  };
30
30
 
31
+ export interface SyncNotificationContent {
32
+ notificationTitle: string;
33
+ notificationContent: string;
34
+ channelName: string;
35
+ channelDescription: string;
36
+ }
37
+
31
38
  export class VitalHealth {
32
39
  static status = new NativeEventEmitter(VitalHealthReactNative);
33
40
 
41
+ static get canEnableBackgroundSyncNoninteractively(): boolean {
42
+ return Platform.OS !== 'android';
43
+ }
44
+
45
+ /**
46
+ * Whether health data sync is paused at the moment.
47
+ */
48
+ static get pauseSynchronization(): Promise<boolean> {
49
+ return VitalHealthReactNative.getPauseSynchronization();
50
+ }
51
+
52
+ /**
53
+ * [Android ONLY][Experimental API]
54
+ * On iOS, this property always returns `true`. iOS HealthKit Background Delivery is
55
+ * an app-level entitlement, and does not require explicit user consent.
56
+ *
57
+ * ## Overview
58
+ *
59
+ * Whether Background Sync on Android is enabled at the moment.
60
+ */
61
+ static get isBackgroundSyncEnabled(): Promise<boolean> {
62
+ if (Platform.OS !== 'android') {
63
+ return Promise.resolve(true);
64
+ }
65
+
66
+ return VitalHealthReactNative.isBackgroundSyncEnabled();
67
+ }
68
+
34
69
  static isAvailable(): Promise<boolean> {
35
70
  if (Platform.OS === 'android') {
36
71
  return VitalHealthReactNative.isAvailable();
@@ -73,6 +108,105 @@ export class VitalHealth {
73
108
  );
74
109
  }
75
110
 
111
+ /**
112
+ * [Android ONLY][Experimental API]
113
+ * On iOS, this method is a no-op returning `true`. iOS HealthKit Background Delivery is an app-level
114
+ * entitlement, and does not require explicit user consent.
115
+ *
116
+ * If you intend to pause or unpause synchronization, use `pauseSynchronization`
117
+ * and `setPauseSynchronization(_:)` instead.
118
+ *
119
+ * ## Overview
120
+ *
121
+ * Enable background sync on Android. This includes requesting permissions from the end user whenever necessary.
122
+ *
123
+ * Vital SDK achieves automatic data sync through Android [AlarmManager] exact alarms.
124
+ *
125
+ * Refer to the [Vital Health Connect guide for full context and setup instructions](https://docs.tryvital.io/wearables/guides/android_health_connect).
126
+ *
127
+ * ## Gist on Exact Alarms
128
+ *
129
+ * "Exact Alarm" here refers to the Android Exact Alarm mechanism. The Vital SDK would propose
130
+ * to the Android OS to fire the next data sync with a T+60min wall clock target. The Android OS
131
+ * may fulfill the request exactly as proposed, e.g., when the user happens to be actively using
132
+ * the device. However, it may also choose to defer it arbitrarily, under the influence of
133
+ * power-saving policies like [Doze mode](https://developer.android.com/training/monitoring-device-state/doze-standby#understand_doze).
134
+ *
135
+ * On Android 12 (API Level 31) or above, this contract would automatically initiate the OS-required
136
+ * user consent flow for Exact Alarm usage. If the permission has been granted prior, this activity
137
+ * contract shall return synchronously.
138
+ *
139
+ * On Android 13 (API Level 33) or above, you have the option to use (with platform policy caveats)
140
+ * the [android.Manifest.permission.USE_EXACT_ALARM] permission instead, which does not require an
141
+ * explicit consent flow. This contract would return synchronously in this scenario.
142
+ *
143
+ * Regardless of API Level, your App Manifest must declare [android.Manifest.permission.RECEIVE_BOOT_COMPLETED].
144
+ * Otherwise, background sync stops once the phone encounters a cold reboot or a quick restart.
145
+ *
146
+ * @return `true` if the background sync has been enabled successfully. `false` otherwise.
147
+ */
148
+ static async enableBackgroundSync(): Promise<boolean> {
149
+ if (Platform.OS !== "android") {
150
+ // iOS background delivery does not require user explicit consent.
151
+ // It requires only the app-level HealthKit Bgnd. Delivery entitlement.
152
+ return true;
153
+ }
154
+
155
+ return await VitalHealthReactNative.enableBackgroundSync();
156
+ }
157
+
158
+ /**
159
+ * [Android ONLY][Experimental API]
160
+ * On iOS, this method is a no-op. iOS HealthKit Background Delivery is an app-level
161
+ * entitlement, and does not require explicit user consent.
162
+ *
163
+ * If you intend to pause or unpause synchronization, use `pauseSynchronization`
164
+ * and `setPauseSynchronization(_:)` instead.
165
+ *
166
+ * ## Overview
167
+ *
168
+ * Disable background sync on Android.
169
+ */
170
+ static async disableBackgroundSync(): Promise<void> {
171
+ if (Platform.OS !== "android") {
172
+ // iOS background delivery does not require user explicit consent.
173
+ // It requires only the app-level HealthKit Bgnd. Delivery entitlement.
174
+ return;
175
+ }
176
+
177
+ return await VitalHealthReactNative.disableBackgroundSync();
178
+ }
179
+
180
+ /**
181
+ * [Android ONLY][Experimental API]
182
+ * On iOS, this method is a no-op. iOS does not require apps to show a user-visible
183
+ * notification when performing extended work in background.
184
+ *
185
+ * ## Overview
186
+ * Set the text content related to the Sync Notification. The OS has full discretion to present
187
+ * this notification to the user, when any data sync work in background is taking longer than expected.
188
+ *
189
+ * Refer to the [Vital Health Connect guide for full context and setup instructions](https://docs.tryvital.io/wearables/guides/android_health_connect).
190
+ */
191
+ static async setSyncNotificationContent(content: SyncNotificationContent): Promise<void> {
192
+ if (Platform.OS !== "android") {
193
+ // iOS background delivery does not require user explicit consent.
194
+ // It requires only the app-level HealthKit Bgnd. Delivery entitlement.
195
+ return;
196
+ }
197
+
198
+ return await VitalHealthReactNative.setSyncNotificationContent(
199
+ JSON.stringify(content)
200
+ );
201
+ }
202
+
203
+ /**
204
+ * Pause or unpause health data sync.
205
+ */
206
+ static async setPauseSynchronization(paused: boolean) {
207
+ return await VitalHealthReactNative.setPauseSynchronization(paused);
208
+ }
209
+
76
210
  static askForResources(resources: VitalResource[]): Promise<void> {
77
211
  return VitalHealthReactNative.ask(resources, []);
78
212
  }