@tryvital/vital-health-react-native 3.0.9 → 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.
- package/android/build/.transforms/56bdc14fef9e29e3b063d932e1530458/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/AskForPermissionContinuation.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/EnableBackgroundSyncContinuation.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$Companion.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$$inlined$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$1$launcher$1$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$1$launcher$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$configure$$inlined$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$disableBackgroundSync$$inlined$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$$inlined$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$1$launcher$1$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$1$launcher$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$getPauseSynchronization$$inlined$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$hasAskedForPermission$$inlined$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$isAvailable$$inlined$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$isBackgroundSyncEnabled$$inlined$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$setPauseSynchronization$$inlined$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$setSyncNotificationContent$$inlined$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$startStatusUpdate$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$syncData$$inlined$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$vitalCore$2.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$writeHealthData$$inlined$runOnMain$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule.dex +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/AskForPermissionContinuation.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/EnableBackgroundSyncContinuation.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$Companion.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$$inlined$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$1$launcher$1$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$1$launcher$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$configure$$inlined$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$disableBackgroundSync$$inlined$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$$inlined$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$1$launcher$1$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$1$launcher$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$getPauseSynchronization$$inlined$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$hasAskedForPermission$$inlined$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$isAvailable$$inlined$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$isBackgroundSyncEnabled$$inlined$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$setPauseSynchronization$$inlined$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$setSyncNotificationContent$$inlined$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$startStatusUpdate$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$syncData$$inlined$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$vitalCore$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$writeHealthData$$inlined$runOnMain$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/AskForPermissionContinuation.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/EnableBackgroundSyncContinuation.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$$inlined$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$1$launcher$1$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$1$launcher$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$configure$$inlined$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$disableBackgroundSync$$inlined$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$$inlined$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$1$launcher$1$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$enableBackgroundSync$1$launcher$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$getPauseSynchronization$$inlined$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$hasAskedForPermission$$inlined$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$isAvailable$$inlined$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$isBackgroundSyncEnabled$$inlined$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$setPauseSynchronization$$inlined$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$setSyncNotificationContent$$inlined$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$startStatusUpdate$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$syncData$$inlined$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$vitalCore$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$writeHealthData$$inlined$runOnMain$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule.class +0 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/vitalhealthreactnative/VitalHealthReactNativeModule.kt +168 -52
- package/ios/VitalHealthReactNative.m +7 -0
- package/ios/VitalHealthReactNative.swift +12 -0
- package/lib/commonjs/index.js +120 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +120 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +88 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +134 -0
- package/vital-health-react-native.podspec +1 -1
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$launcher$1$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$configure$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$syncData$1.dex +0 -0
- package/android/build/.transforms/d7d1f91b4fa9761a2709d6b066727acb/transformed/debug/debug_dex/com/vitalhealthreactnative/VitalHealthReactNativeModule$writeHealthData$1.dex +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$launcher$1$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$configure$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$syncData$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$writeHealthData$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$ask$launcher$1$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$configure$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$syncData$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/vitalhealthreactnative/VitalHealthReactNativeModule$writeHealthData$1.class +0 -0
|
@@ -15,11 +15,21 @@ import com.facebook.react.module.annotations.ReactModule
|
|
|
15
15
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
16
16
|
import com.vitalcorereactnative.VitalCoreReactNativeModule
|
|
17
17
|
import io.tryvital.client.utils.VitalLogger
|
|
18
|
+
import io.tryvital.vitalhealthconnect.DefaultSyncNotificationBuilder
|
|
19
|
+
import io.tryvital.vitalhealthconnect.DefaultSyncNotificationContent
|
|
20
|
+
import io.tryvital.vitalhealthconnect.ExperimentalVitalApi
|
|
18
21
|
import io.tryvital.vitalhealthconnect.VitalHealthConnectManager
|
|
22
|
+
import io.tryvital.vitalhealthconnect.disableBackgroundSync
|
|
23
|
+
import io.tryvital.vitalhealthconnect.enableBackgroundSyncContract
|
|
24
|
+
import io.tryvital.vitalhealthconnect.isBackgroundSyncEnabled
|
|
19
25
|
import io.tryvital.vitalhealthconnect.model.*
|
|
20
26
|
import kotlinx.coroutines.*
|
|
21
27
|
import kotlinx.coroutines.flow.launchIn
|
|
22
28
|
import kotlinx.coroutines.flow.onEach
|
|
29
|
+
import kotlinx.serialization.decodeFromString
|
|
30
|
+
import kotlinx.serialization.json.Json
|
|
31
|
+
import kotlinx.serialization.json.JsonObject
|
|
32
|
+
import kotlinx.serialization.json.jsonPrimitive
|
|
23
33
|
import java.time.Instant
|
|
24
34
|
import java.util.concurrent.atomic.AtomicReference
|
|
25
35
|
|
|
@@ -39,6 +49,7 @@ class VitalHealthReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
39
49
|
get() = VitalHealthConnectManager.getOrCreate(reactApplicationContext)
|
|
40
50
|
|
|
41
51
|
private var askForPermission: AskForPermissionContinuation? = null
|
|
52
|
+
private var enableBackgroundSync: EnableBackgroundSyncContinuation? = null
|
|
42
53
|
|
|
43
54
|
private var mainScope = MainScope()
|
|
44
55
|
|
|
@@ -47,7 +58,7 @@ class VitalHealthReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
47
58
|
}
|
|
48
59
|
|
|
49
60
|
@ReactMethod
|
|
50
|
-
fun isAvailable(promise: Promise) {
|
|
61
|
+
fun isAvailable(promise: Promise) = runOnMain {
|
|
51
62
|
val availability = VitalHealthConnectManager.isAvailable(reactApplicationContext)
|
|
52
63
|
promise.resolve(availability == HealthConnectAvailability.Installed)
|
|
53
64
|
}
|
|
@@ -58,15 +69,15 @@ class VitalHealthReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
58
69
|
numberOfDaysToBackFill: Int,
|
|
59
70
|
enableLogs: Boolean,
|
|
60
71
|
promise: Promise
|
|
61
|
-
) {
|
|
72
|
+
) = runOnMain {
|
|
62
73
|
logger.enabled = enableLogs
|
|
63
74
|
|
|
64
75
|
val availability = VitalHealthConnectManager.isAvailable(reactApplicationContext)
|
|
65
76
|
|
|
66
77
|
if (availability != HealthConnectAvailability.Installed) {
|
|
67
|
-
return promise.reject(
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
return@runOnMain promise.reject(
|
|
79
|
+
VITAL_HEALTH_ERROR,
|
|
80
|
+
"Health Connect is unavailable: $availability",
|
|
70
81
|
)
|
|
71
82
|
}
|
|
72
83
|
|
|
@@ -75,19 +86,17 @@ class VitalHealthReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
75
86
|
// Start status observation before we do anything that can update it.
|
|
76
87
|
manager.startStatusUpdate()
|
|
77
88
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
89
|
+
manager.configureHealthConnectClient(
|
|
90
|
+
logsEnabled = enableLogs,
|
|
91
|
+
syncOnAppStart = syncOnAppStart,
|
|
92
|
+
numberOfDaysToBackFill = numberOfDaysToBackFill,
|
|
93
|
+
)
|
|
84
94
|
|
|
85
|
-
|
|
86
|
-
}
|
|
95
|
+
promise.resolve(null)
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
@ReactMethod
|
|
90
|
-
fun setUserId(userId: String, promise: Promise)
|
|
99
|
+
fun setUserId(userId: String, promise: Promise) {
|
|
91
100
|
// [Backward Compatibility] Delegate to VitalCore.
|
|
92
101
|
vitalCore.setUserId(userId, promise)
|
|
93
102
|
}
|
|
@@ -117,24 +126,24 @@ class VitalHealthReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
117
126
|
readResources: ReadableArray,
|
|
118
127
|
writeResources: ReadableArray?,
|
|
119
128
|
promise: Promise
|
|
120
|
-
) {
|
|
129
|
+
) = runOnMain {
|
|
121
130
|
val manager = vitalHealthConnectManager
|
|
122
131
|
if (synchronized(this) { this.askForPermission != null }) {
|
|
123
|
-
return promise.reject(
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
return@runOnMain promise.reject(
|
|
133
|
+
VITAL_HEALTH_ERROR,
|
|
134
|
+
"Another ask for permission call is already in progress."
|
|
126
135
|
)
|
|
127
136
|
}
|
|
128
137
|
|
|
129
|
-
val activity = currentActivity ?: return promise.reject(
|
|
138
|
+
val activity = currentActivity ?: return@runOnMain promise.reject(
|
|
130
139
|
VITAL_HEALTH_ERROR,
|
|
131
140
|
"Cannot find the current ReactNative Activity"
|
|
132
141
|
)
|
|
133
142
|
|
|
134
143
|
if (activity !is ComponentActivity) {
|
|
135
|
-
return promise.reject(
|
|
136
|
-
|
|
137
|
-
|
|
144
|
+
return@runOnMain promise.reject(
|
|
145
|
+
VITAL_HEALTH_ERROR,
|
|
146
|
+
"The Android Activity class of your React Native host app must be a androidx.activity.ComponentActivity subclass for the permission request flow to function properly."
|
|
138
147
|
)
|
|
139
148
|
}
|
|
140
149
|
|
|
@@ -142,14 +151,14 @@ class VitalHealthReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
142
151
|
try {
|
|
143
152
|
VitalResource.valueOf(it as String)
|
|
144
153
|
} catch (e: IllegalArgumentException) {
|
|
145
|
-
return@
|
|
154
|
+
return@runOnMain promise.reject(VITAL_HEALTH_ERROR, "Unrecognized vital resource: $it")
|
|
146
155
|
}
|
|
147
156
|
}
|
|
148
157
|
val write = writeResources?.toArrayList()?.mapTo(mutableSetOf()) {
|
|
149
158
|
try {
|
|
150
159
|
WritableVitalResource.valueOf(it as String)
|
|
151
160
|
} catch (e: IllegalArgumentException) {
|
|
152
|
-
return@
|
|
161
|
+
return@runOnMain promise.reject(VITAL_HEALTH_ERROR, "Unrecognized vital resource: $it")
|
|
153
162
|
}
|
|
154
163
|
} ?: setOf()
|
|
155
164
|
val contract = manager.createPermissionRequestContract(
|
|
@@ -184,19 +193,19 @@ class VitalHealthReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
184
193
|
}
|
|
185
194
|
|
|
186
195
|
@ReactMethod
|
|
187
|
-
fun hasAskedForPermission(resource: String, promise: Promise) {
|
|
196
|
+
fun hasAskedForPermission(resource: String, promise: Promise) = runOnMain {
|
|
188
197
|
val manager = vitalHealthConnectManager
|
|
189
198
|
val vitalResource = try {
|
|
190
199
|
VitalResource.valueOf(resource)
|
|
191
200
|
} catch (e: IllegalArgumentException) {
|
|
192
|
-
return promise.reject(VITAL_HEALTH_ERROR, "Unrecognized vital resource: $resource")
|
|
201
|
+
return@runOnMain promise.reject(VITAL_HEALTH_ERROR, "Unrecognized vital resource: $resource")
|
|
193
202
|
}
|
|
194
203
|
|
|
195
204
|
promise.resolve(manager.hasAskedForPermission(vitalResource))
|
|
196
205
|
}
|
|
197
206
|
|
|
198
207
|
@ReactMethod
|
|
199
|
-
fun syncData(resources: ReadableArray, promise: Promise) {
|
|
208
|
+
fun syncData(resources: ReadableArray, promise: Promise) = runOnMain {
|
|
200
209
|
val manager = vitalHealthConnectManager
|
|
201
210
|
|
|
202
211
|
val vitalResources = resources.toArrayList().toList()
|
|
@@ -205,19 +214,17 @@ class VitalHealthReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
205
214
|
VitalResource.valueOf(it.toString())
|
|
206
215
|
} catch (e: IllegalArgumentException) {
|
|
207
216
|
promise.reject("VitalHealthError", "Unrecognized vital resource: $it")
|
|
208
|
-
return@
|
|
217
|
+
return@runOnMain
|
|
209
218
|
}
|
|
210
219
|
}
|
|
211
220
|
.toSet()
|
|
212
221
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
promise.reject(e)
|
|
220
|
-
}
|
|
222
|
+
// Treat empty set as "sync all" (resources = null)
|
|
223
|
+
try {
|
|
224
|
+
manager.syncData(resources = vitalResources.ifEmpty { null })
|
|
225
|
+
promise.resolve(null)
|
|
226
|
+
} catch (e: Throwable) {
|
|
227
|
+
promise.reject(e)
|
|
221
228
|
}
|
|
222
229
|
}
|
|
223
230
|
|
|
@@ -228,34 +235,129 @@ class VitalHealthReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
228
235
|
endDate: Long,
|
|
229
236
|
value: Double,
|
|
230
237
|
promise: Promise
|
|
231
|
-
) {
|
|
238
|
+
) = runOnMain {
|
|
232
239
|
val manager = vitalHealthConnectManager
|
|
233
240
|
|
|
234
241
|
val writableResource = try {
|
|
235
242
|
WritableVitalResource.valueOf(resource)
|
|
236
243
|
} catch (e: IllegalArgumentException) {
|
|
237
|
-
return promise.reject("VitalHealthError", "Unrecognized writable resource: $resource")
|
|
244
|
+
return@runOnMain promise.reject("VitalHealthError", "Unrecognized writable resource: $resource")
|
|
238
245
|
}
|
|
239
246
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
247
|
+
try {
|
|
248
|
+
manager.writeRecord(
|
|
249
|
+
writableResource,
|
|
250
|
+
startDate = Instant.ofEpochMilli(startDate),
|
|
251
|
+
endDate = Instant.ofEpochMilli(endDate),
|
|
252
|
+
value = value,
|
|
253
|
+
)
|
|
254
|
+
promise.resolve(null)
|
|
255
|
+
} catch (e: Exception) {
|
|
256
|
+
promise.reject(
|
|
257
|
+
VITAL_HEALTH_ERROR,
|
|
258
|
+
"Failed to write data: ${e.message}",
|
|
259
|
+
e
|
|
260
|
+
)
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
@OptIn(ExperimentalVitalApi::class)
|
|
265
|
+
@ReactMethod
|
|
266
|
+
fun enableBackgroundSync(promise: Promise) = runOnMain {
|
|
267
|
+
val manager = vitalHealthConnectManager
|
|
268
|
+
if (synchronized(this) { this.enableBackgroundSync != null }) {
|
|
269
|
+
return@runOnMain promise.reject(
|
|
270
|
+
VITAL_HEALTH_ERROR,
|
|
271
|
+
"Another enableBackgroundSync call is already in progress."
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
val activity = currentActivity ?: return@runOnMain promise.reject(
|
|
276
|
+
VITAL_HEALTH_ERROR,
|
|
277
|
+
"Cannot find the current ReactNative Activity"
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
if (activity !is ComponentActivity) {
|
|
281
|
+
return@runOnMain promise.reject(
|
|
282
|
+
VITAL_HEALTH_ERROR,
|
|
283
|
+
"The Android Activity class of your React Native host app must be a androidx.activity.ComponentActivity subclass for the permission request flow to function properly."
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
val contract = manager.enableBackgroundSyncContract()
|
|
288
|
+
|
|
289
|
+
synchronized(this) {
|
|
290
|
+
enableBackgroundSync = EnableBackgroundSyncContinuation(contract, promise)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
val registry = activity.activityResultRegistry
|
|
294
|
+
val launcherRef = AtomicReference<ActivityResultLauncher<*>>(null)
|
|
295
|
+
val launcher = registry.register("io.tryvital.health.enableBackgroundSync", contract) { success ->
|
|
296
|
+
val continuation = synchronized(this) {
|
|
297
|
+
val currentValue = enableBackgroundSync
|
|
298
|
+
enableBackgroundSync = null
|
|
299
|
+
return@synchronized currentValue
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
val launcher = launcherRef.getAndSet(null)
|
|
303
|
+
launcher?.unregister()
|
|
304
|
+
|
|
305
|
+
if (continuation != null) {
|
|
306
|
+
mainScope.launch {
|
|
307
|
+
continuation.promise.resolve(success)
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
launcherRef.set(launcher)
|
|
312
|
+
launcher.launch(Unit)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
@OptIn(ExperimentalVitalApi::class)
|
|
316
|
+
@ReactMethod
|
|
317
|
+
fun disableBackgroundSync(promise: Promise) = runOnMain {
|
|
318
|
+
vitalHealthConnectManager.disableBackgroundSync()
|
|
319
|
+
promise.resolve(null)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
@ReactMethod
|
|
323
|
+
fun setSyncNotificationContent(content: String, promise: Promise) = runOnMain {
|
|
324
|
+
val builder = vitalHealthConnectManager.syncNotificationBuilder as? DefaultSyncNotificationBuilder
|
|
325
|
+
?: return@runOnMain promise.resolve(null)
|
|
326
|
+
|
|
327
|
+
try {
|
|
328
|
+
val payload = Json.decodeFromString<JsonObject>(content).let {
|
|
329
|
+
DefaultSyncNotificationContent(
|
|
330
|
+
notificationTitle = it["notificationTitle"]!!.jsonPrimitive.toString(),
|
|
331
|
+
notificationContent = it["notificationContent"]!!.jsonPrimitive.toString(),
|
|
332
|
+
channelName = it["channelName"]!!.jsonPrimitive.toString(),
|
|
333
|
+
channelDescription = it["channelDescription"]!!.jsonPrimitive.toString(),
|
|
254
334
|
)
|
|
255
335
|
}
|
|
336
|
+
|
|
337
|
+
builder.setContentOverride(payload)
|
|
338
|
+
promise.resolve(null)
|
|
339
|
+
} catch (e: Exception) {
|
|
340
|
+
promise.reject(VITAL_HEALTH_ERROR, "Failed to decode the supplied notification content", e)
|
|
256
341
|
}
|
|
257
342
|
}
|
|
258
343
|
|
|
344
|
+
@ReactMethod
|
|
345
|
+
fun setPauseSynchronization(paused: Boolean, promise: Promise) = runOnMain {
|
|
346
|
+
vitalHealthConnectManager.pauseSynchronization = paused
|
|
347
|
+
promise.resolve(null)
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
@ReactMethod
|
|
351
|
+
fun getPauseSynchronization(promise: Promise) = runOnMain {
|
|
352
|
+
promise.resolve(vitalHealthConnectManager.pauseSynchronization)
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
@OptIn(ExperimentalVitalApi::class)
|
|
356
|
+
@ReactMethod
|
|
357
|
+
fun isBackgroundSyncEnabled(promise: Promise) = runOnMain {
|
|
358
|
+
promise.resolve(vitalHealthConnectManager.isBackgroundSyncEnabled)
|
|
359
|
+
}
|
|
360
|
+
|
|
259
361
|
@ReactMethod
|
|
260
362
|
fun addListener(eventName: String?) {
|
|
261
363
|
// Keep: Required for RN built in Event Emitter Calls.
|
|
@@ -327,6 +429,11 @@ class VitalHealthReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
327
429
|
companion object {
|
|
328
430
|
const val NAME = "VitalHealthReactNative"
|
|
329
431
|
|
|
432
|
+
@JvmStatic
|
|
433
|
+
fun enableDebugLogging() {
|
|
434
|
+
VitalLogger.getOrCreate().enabled = true
|
|
435
|
+
}
|
|
436
|
+
|
|
330
437
|
/**
|
|
331
438
|
* This method is a workaround which manually dispatches request permission results back to
|
|
332
439
|
* where the Health Connect activity contract expects it.
|
|
@@ -359,9 +466,18 @@ class VitalHealthReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
359
466
|
}
|
|
360
467
|
}
|
|
361
468
|
}
|
|
469
|
+
|
|
470
|
+
private inline fun runOnMain(crossinline action: suspend () -> Unit) {
|
|
471
|
+
mainScope.launch { action() }
|
|
472
|
+
}
|
|
362
473
|
}
|
|
363
474
|
|
|
364
475
|
private data class AskForPermissionContinuation(
|
|
365
476
|
val contract: ActivityResultContract<Unit, Deferred<PermissionOutcome>>,
|
|
366
477
|
val promise: Promise
|
|
367
478
|
)
|
|
479
|
+
|
|
480
|
+
private data class EnableBackgroundSyncContinuation(
|
|
481
|
+
val contract: ActivityResultContract<Unit, Boolean>,
|
|
482
|
+
val promise: Promise
|
|
483
|
+
)
|
|
@@ -43,6 +43,13 @@ RCT_EXTERN_METHOD(syncData:(NSArray<NSString *> *)resources
|
|
|
43
43
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
44
44
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
45
45
|
|
|
46
|
+
RCT_EXTERN_METHOD(getPauseSynchronization:(RCTPromiseResolveBlock)resolve
|
|
47
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
48
|
+
|
|
49
|
+
RCT_EXTERN_METHOD(setPauseSynchronization:(BOOL)resource
|
|
50
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
51
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
52
|
+
|
|
46
53
|
RCT_EXTERN_METHOD(status)
|
|
47
54
|
|
|
48
55
|
+ (BOOL)requiresMainQueueSetup
|
|
@@ -218,6 +218,18 @@ class VitalHealthReactNative: RCTEventEmitter {
|
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
|
|
222
|
+
@objc(getPauseSynchronization:rejecter:)
|
|
223
|
+
func getPauseSynchronization(_ resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
|
|
224
|
+
resolve(VitalHealthKitClient.shared.pauseSynchronization)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@objc(setPauseSynchronization:resolver:rejecter:)
|
|
228
|
+
func setPauseSynchronization(_ paused: Bool, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
|
|
229
|
+
VitalHealthKitClient.shared.pauseSynchronization = paused
|
|
230
|
+
resolve(())
|
|
231
|
+
}
|
|
232
|
+
|
|
221
233
|
}
|
|
222
234
|
|
|
223
235
|
private func mapResourceToReadableVitalResource(_ name: String) throws -> VitalResource {
|
package/lib/commonjs/index.js
CHANGED
|
@@ -42,6 +42,32 @@ const VitalHealthEvents = exports.VitalHealthEvents = {
|
|
|
42
42
|
};
|
|
43
43
|
class VitalHealth {
|
|
44
44
|
static status = new _reactNative.NativeEventEmitter(VitalHealthReactNative);
|
|
45
|
+
static get canEnableBackgroundSyncNoninteractively() {
|
|
46
|
+
return _reactNative.Platform.OS !== 'android';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Whether health data sync is paused at the moment.
|
|
51
|
+
*/
|
|
52
|
+
static get pauseSynchronization() {
|
|
53
|
+
return VitalHealthReactNative.getPauseSynchronization();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* [Android ONLY][Experimental API]
|
|
58
|
+
* On iOS, this property always returns `true`. iOS HealthKit Background Delivery is
|
|
59
|
+
* an app-level entitlement, and does not require explicit user consent.
|
|
60
|
+
*
|
|
61
|
+
* ## Overview
|
|
62
|
+
*
|
|
63
|
+
* Whether Background Sync on Android is enabled at the moment.
|
|
64
|
+
*/
|
|
65
|
+
static get isBackgroundSyncEnabled() {
|
|
66
|
+
if (_reactNative.Platform.OS !== 'android') {
|
|
67
|
+
return Promise.resolve(true);
|
|
68
|
+
}
|
|
69
|
+
return VitalHealthReactNative.isBackgroundSyncEnabled();
|
|
70
|
+
}
|
|
45
71
|
static isAvailable() {
|
|
46
72
|
if (_reactNative.Platform.OS === 'android') {
|
|
47
73
|
return VitalHealthReactNative.isAvailable();
|
|
@@ -62,6 +88,100 @@ class VitalHealth {
|
|
|
62
88
|
static configureClient(apiKey, environment, region, enableLogs) {
|
|
63
89
|
return VitalHealthReactNative.configureClient(apiKey, environment, region, enableLogs);
|
|
64
90
|
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* [Android ONLY][Experimental API]
|
|
94
|
+
* On iOS, this method is a no-op returning `true`. iOS HealthKit Background Delivery is an app-level
|
|
95
|
+
* entitlement, and does not require explicit user consent.
|
|
96
|
+
*
|
|
97
|
+
* If you intend to pause or unpause synchronization, use `pauseSynchronization`
|
|
98
|
+
* and `setPauseSynchronization(_:)` instead.
|
|
99
|
+
*
|
|
100
|
+
* ## Overview
|
|
101
|
+
*
|
|
102
|
+
* Enable background sync on Android. This includes requesting permissions from the end user whenever necessary.
|
|
103
|
+
*
|
|
104
|
+
* Vital SDK achieves automatic data sync through Android [AlarmManager] exact alarms.
|
|
105
|
+
*
|
|
106
|
+
* Refer to the [Vital Health Connect guide for full context and setup instructions](https://docs.tryvital.io/wearables/guides/android_health_connect).
|
|
107
|
+
*
|
|
108
|
+
* ## Gist on Exact Alarms
|
|
109
|
+
*
|
|
110
|
+
* "Exact Alarm" here refers to the Android Exact Alarm mechanism. The Vital SDK would propose
|
|
111
|
+
* to the Android OS to fire the next data sync with a T+60min wall clock target. The Android OS
|
|
112
|
+
* may fulfill the request exactly as proposed, e.g., when the user happens to be actively using
|
|
113
|
+
* the device. However, it may also choose to defer it arbitrarily, under the influence of
|
|
114
|
+
* power-saving policies like [Doze mode](https://developer.android.com/training/monitoring-device-state/doze-standby#understand_doze).
|
|
115
|
+
*
|
|
116
|
+
* On Android 12 (API Level 31) or above, this contract would automatically initiate the OS-required
|
|
117
|
+
* user consent flow for Exact Alarm usage. If the permission has been granted prior, this activity
|
|
118
|
+
* contract shall return synchronously.
|
|
119
|
+
*
|
|
120
|
+
* On Android 13 (API Level 33) or above, you have the option to use (with platform policy caveats)
|
|
121
|
+
* the [android.Manifest.permission.USE_EXACT_ALARM] permission instead, which does not require an
|
|
122
|
+
* explicit consent flow. This contract would return synchronously in this scenario.
|
|
123
|
+
*
|
|
124
|
+
* Regardless of API Level, your App Manifest must declare [android.Manifest.permission.RECEIVE_BOOT_COMPLETED].
|
|
125
|
+
* Otherwise, background sync stops once the phone encounters a cold reboot or a quick restart.
|
|
126
|
+
*
|
|
127
|
+
* @return `true` if the background sync has been enabled successfully. `false` otherwise.
|
|
128
|
+
*/
|
|
129
|
+
static async enableBackgroundSync() {
|
|
130
|
+
if (_reactNative.Platform.OS !== "android") {
|
|
131
|
+
// iOS background delivery does not require user explicit consent.
|
|
132
|
+
// It requires only the app-level HealthKit Bgnd. Delivery entitlement.
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
return await VitalHealthReactNative.enableBackgroundSync();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* [Android ONLY][Experimental API]
|
|
140
|
+
* On iOS, this method is a no-op. iOS HealthKit Background Delivery is an app-level
|
|
141
|
+
* entitlement, and does not require explicit user consent.
|
|
142
|
+
*
|
|
143
|
+
* If you intend to pause or unpause synchronization, use `pauseSynchronization`
|
|
144
|
+
* and `setPauseSynchronization(_:)` instead.
|
|
145
|
+
*
|
|
146
|
+
* ## Overview
|
|
147
|
+
*
|
|
148
|
+
* Disable background sync on Android.
|
|
149
|
+
*/
|
|
150
|
+
static async disableBackgroundSync() {
|
|
151
|
+
if (_reactNative.Platform.OS !== "android") {
|
|
152
|
+
// iOS background delivery does not require user explicit consent.
|
|
153
|
+
// It requires only the app-level HealthKit Bgnd. Delivery entitlement.
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
return await VitalHealthReactNative.disableBackgroundSync();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* [Android ONLY][Experimental API]
|
|
161
|
+
* On iOS, this method is a no-op. iOS does not require apps to show a user-visible
|
|
162
|
+
* notification when performing extended work in background.
|
|
163
|
+
*
|
|
164
|
+
* ## Overview
|
|
165
|
+
* Set the text content related to the Sync Notification. The OS has full discretion to present
|
|
166
|
+
* this notification to the user, when any data sync work in background is taking longer than expected.
|
|
167
|
+
*
|
|
168
|
+
* Refer to the [Vital Health Connect guide for full context and setup instructions](https://docs.tryvital.io/wearables/guides/android_health_connect).
|
|
169
|
+
*/
|
|
170
|
+
static async setSyncNotificationContent(content) {
|
|
171
|
+
if (_reactNative.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
|
+
return await VitalHealthReactNative.setSyncNotificationContent(JSON.stringify(content));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Pause or unpause health data sync.
|
|
181
|
+
*/
|
|
182
|
+
static async setPauseSynchronization(paused) {
|
|
183
|
+
return await VitalHealthReactNative.setPauseSynchronization(paused);
|
|
184
|
+
}
|
|
65
185
|
static askForResources(resources) {
|
|
66
186
|
return VitalHealthReactNative.ask(resources, []);
|
|
67
187
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_vitalCoreReactNative","_health_config","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","LINKING_ERROR","Platform","select","ios","default","VitalHealthReactNative","NativeModules","Proxy","Error","VitalHealthReactNativeModule","VitalHealthEvents","statusEvent","VitalHealth","status","NativeEventEmitter","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_vitalCoreReactNative","_health_config","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","LINKING_ERROR","Platform","select","ios","default","VitalHealthReactNative","NativeModules","Proxy","Error","VitalHealthReactNativeModule","VitalHealthEvents","statusEvent","VitalHealth","status","NativeEventEmitter","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","VitalCore","signOut","VitalResource","VitalWriteResource"],"s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