react-native-rook-sdk 4.0.0-beta.2 → 4.0.0
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/LICENSE +1 -1
- package/README.md +3 -35
- package/android/build.gradle +45 -20
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +2 -1
- package/android/src/main/AndroidManifestNew.xml +36 -0
- package/android/src/main/java/com/rooksdk/RookSdkModule.kt +263 -11
- package/android/src/main/java/com/rooksdk/RookSdkPackage.kt +42 -26
- package/android/src/main/java/com/rooksdk/broadcasts/AndroidPermissionsReceiverTransmitter.kt +65 -0
- package/android/src/main/java/com/rooksdk/broadcasts/HealthConnectPermissionsReceiverTransmitter.kt +70 -0
- package/android/src/main/java/com/rooksdk/broadcasts/SamsungHealthPermissionsReceiverTransmitter.kt +52 -0
- package/android/src/main/java/com/rooksdk/modules/RookBackgroundSyncModule.kt +99 -0
- package/android/src/main/java/com/rooksdk/modules/RookConfigurationModule.kt +182 -0
- package/android/src/main/java/com/rooksdk/modules/RookLocalData.kt +301 -0
- package/android/src/main/java/com/rooksdk/modules/RookPermissionsModule.kt +359 -0
- package/android/src/main/java/com/rooksdk/modules/RookSourcesModule.kt +102 -0
- package/android/src/main/java/com/rooksdk/modules/RookStepsModule.kt +119 -0
- package/android/src/main/java/com/rooksdk/modules/RookSyncModule.kt +551 -0
- package/android/src/main/java/com/rooksdk/utils/DatasourcesUtils.kt +34 -0
- package/android/src/main/java/com/rooksdk/utils/PermissionConversion.kt +21 -0
- package/android/src/main/java/com/rooksdk/utils/ReadableToWritable.kt +145 -0
- package/android/src/main/java/com/rooksdk/utils/RookDateTime.kt +26 -0
- package/android/src/main/java/com/rooksdk/utils/RookGsonBuilder.kt +17 -0
- package/android/src/main/java/com/rooksdk/utils/SamsungAvailability.kt +21 -0
- package/android/src/main/java/com/rooksdk/utils/Source.kt +6 -0
- package/android/src/main/java/com/rooksdk/utils/StringToSyncType.kt +41 -0
- package/android/src/main/java/com/rooksdk/utils/serializers/InstantSerializer.kt +19 -0
- package/android/src/main/java/com/rooksdk/utils/serializers/LocalDateSerializer.kt +21 -0
- package/android/src/main/res/drawable/ic_health_connect.xml +19 -0
- package/android/src/main/res/values/themes.xml +3 -0
- package/ios/DateHelper.swift +4 -4
- package/ios/EncodableDataSource.swift +3 -2
- package/ios/EncodableDataSourceAuthorizer.swift +3 -2
- package/ios/{HearRateMapper.swift → EncodableHeartRate.swift} +3 -3
- package/ios/EncodableRookDataSource.swift +36 -0
- package/ios/EncodableSDKState.swift +94 -0
- package/ios/EncodableStatusDataSources.swift +47 -0
- package/ios/NutritionMapper.swift +114 -0
- package/ios/RookBackground.swift +8 -5
- package/ios/RookBackgroundModule.h +5 -0
- package/ios/RookBackgroundModule.mm +15 -0
- package/ios/RookConfiguration.swift +34 -24
- package/ios/RookConfigurationModule.h +5 -0
- package/ios/RookConfigurationModule.mm +22 -0
- package/ios/RookExternalModule.h +5 -0
- package/ios/RookExternalModule.m +31 -0
- package/ios/{RookData.swift → RookLocalData.swift} +70 -48
- package/ios/RookPermissions.swift +33 -5
- package/ios/RookPermissionsModule.h +5 -0
- package/ios/RookPermissionsModule.mm +20 -0
- package/ios/RookSdk.h +2 -14
- package/ios/RookSdk.mm +97 -546
- package/ios/RookSources.swift +54 -60
- package/ios/RookSourcesModule.h +5 -0
- package/ios/RookSourcesModule.mm +18 -0
- package/ios/RookSync.h +5 -0
- package/ios/RookSync.m +35 -0
- package/ios/RookSync.swift +78 -48
- package/ios/SwiftTest.swift +18 -0
- package/ios/react-native-rook-sdk-Bridging-Header.h +12 -0
- package/{src/context/RookSyncGateContext.ts → lib/commonjs/context/RookSyncGateContext.js} +13 -10
- package/lib/commonjs/context/RookSyncGateContext.js.map +1 -0
- package/lib/commonjs/context/RookSyncGateProvider.js +108 -0
- package/lib/commonjs/context/RookSyncGateProvider.js.map +1 -0
- package/{src/context/RookSyncGateReducer.ts → lib/commonjs/context/RookSyncGateReducer.js} +44 -13
- package/lib/commonjs/context/RookSyncGateReducer.js.map +1 -0
- package/lib/commonjs/context/RookSyncGateTypes.js +6 -0
- package/lib/commonjs/context/RookSyncGateTypes.js.map +1 -0
- package/lib/commonjs/context/index.js +14 -0
- package/lib/commonjs/context/index.js.map +1 -0
- package/lib/commonjs/hooks/index.js +76 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/{src/hooks/useRookAPISources.ts → lib/commonjs/hooks/useRookAPISources.js} +36 -40
- package/lib/commonjs/hooks/useRookAPISources.js.map +1 -0
- package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js +88 -0
- package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js.map +1 -0
- package/lib/commonjs/hooks/useRookAppleHealth.js +63 -0
- package/lib/commonjs/hooks/useRookAppleHealth.js.map +1 -0
- package/lib/commonjs/hooks/useRookConfiguration.js +113 -0
- package/lib/commonjs/hooks/useRookConfiguration.js.map +1 -0
- package/lib/commonjs/hooks/useRookData.js +116 -0
- package/lib/commonjs/hooks/useRookData.js.map +1 -0
- package/lib/commonjs/hooks/useRookHealthConnect.js +70 -0
- package/lib/commonjs/hooks/useRookHealthConnect.js.map +1 -0
- package/lib/commonjs/hooks/useRookPermissions.js +211 -0
- package/lib/commonjs/hooks/useRookPermissions.js.map +1 -0
- package/lib/commonjs/hooks/useRookSamsungHealth.js +54 -0
- package/lib/commonjs/hooks/useRookSamsungHealth.js.map +1 -0
- package/lib/commonjs/hooks/useRookSync.js +148 -0
- package/lib/commonjs/hooks/useRookSync.js.map +1 -0
- package/lib/commonjs/hooks/useRookVariables.js +93 -0
- package/lib/commonjs/hooks/useRookVariables.js.map +1 -0
- package/lib/commonjs/index.js +121 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/modules/hook/useRookAutoSync.js +261 -0
- package/lib/commonjs/modules/hook/useRookAutoSync.js.map +1 -0
- package/lib/commonjs/modules/types/sendMessageBroadcast.js +2 -0
- package/lib/commonjs/modules/types/sendMessageBroadcast.js.map +1 -0
- package/lib/commonjs/modules/utils/errors.js +12 -0
- package/lib/commonjs/modules/utils/errors.js.map +1 -0
- package/lib/commonjs/types/ActivityEvent.js +6 -0
- package/lib/commonjs/types/ActivityEvent.js.map +1 -0
- package/lib/commonjs/types/AppleHealthNutritionEvent.js +77 -0
- package/lib/commonjs/types/AppleHealthNutritionEvent.js.map +1 -0
- package/lib/commonjs/types/AppleHealthPermissions.js +57 -0
- package/lib/commonjs/types/AppleHealthPermissions.js.map +1 -0
- package/lib/commonjs/types/AuthorizedSources.js +6 -0
- package/lib/commonjs/types/AuthorizedSources.js.map +1 -0
- package/lib/commonjs/types/BodySummary.js +6 -0
- package/lib/{module/types/Rook.js.map → commonjs/types/BodySummary.js.map} +1 -1
- package/lib/commonjs/types/DataSource.js +16 -0
- package/lib/commonjs/types/DataSource.js.map +1 -0
- package/lib/commonjs/types/DiagnosticState.js +2 -0
- package/lib/commonjs/types/DiagnosticState.js.map +1 -0
- package/lib/commonjs/types/HCMealData.js +65 -0
- package/lib/commonjs/types/HCMealData.js.map +1 -0
- package/lib/commonjs/types/HeartRateEvent.js +2 -0
- package/lib/commonjs/types/HeartRateEvent.js.map +1 -0
- package/lib/commonjs/types/PermissionsType.js +2 -0
- package/lib/commonjs/types/PermissionsType.js.map +1 -0
- package/lib/commonjs/types/PhysicalSummary.js +6 -0
- package/lib/commonjs/types/PhysicalSummary.js.map +1 -0
- package/lib/commonjs/types/SDKSources.js +13 -0
- package/lib/commonjs/types/SDKSources.js.map +1 -0
- package/lib/commonjs/types/SamsungHealthPermissions.js +23 -0
- package/lib/commonjs/types/SamsungHealthPermissions.js.map +1 -0
- package/lib/commonjs/types/SleepSummary.js +6 -0
- package/lib/commonjs/types/SleepSummary.js.map +1 -0
- package/lib/commonjs/types/SummaryTypes.js +2 -0
- package/lib/commonjs/types/SummaryTypes.js.map +1 -0
- package/lib/commonjs/types/SyncTypes.js +33 -0
- package/lib/commonjs/types/SyncTypes.js.map +1 -0
- package/lib/commonjs/types/WriteNutrition.js +18 -0
- package/lib/commonjs/types/WriteNutrition.js.map +1 -0
- package/lib/commonjs/utils/getNativeModule.js +29 -0
- package/lib/commonjs/utils/getNativeModule.js.map +1 -0
- package/lib/commonjs/utils/getRookModule.js +28 -0
- package/lib/commonjs/utils/getRookModule.js.map +1 -0
- package/{src/utils/isModuleReady.ts → lib/commonjs/utils/isModuleReady.js} +10 -4
- package/lib/commonjs/utils/isModuleReady.js.map +1 -0
- package/lib/commonjs/utils/isRunningOnAndroid.js +15 -0
- package/lib/commonjs/utils/isRunningOnAndroid.js.map +1 -0
- package/lib/commonjs/utils/isRunningOniOS.js +15 -0
- package/lib/commonjs/utils/isRunningOniOS.js.map +1 -0
- package/lib/commonjs/utils/isValidDate.js +41 -0
- package/lib/commonjs/utils/isValidDate.js.map +1 -0
- package/lib/commonjs/utils/nativeModules.js +29 -0
- package/lib/commonjs/utils/nativeModules.js.map +1 -0
- package/lib/commonjs/utils/packageInfo.js +13 -0
- package/lib/commonjs/utils/packageInfo.js.map +1 -0
- package/lib/module/context/RookSyncGateContext.js +0 -2
- package/lib/module/context/RookSyncGateContext.js.map +1 -1
- package/lib/module/context/RookSyncGateProvider.js +31 -22
- package/lib/module/context/RookSyncGateProvider.js.map +1 -1
- package/lib/module/context/RookSyncGateReducer.js +12 -4
- package/lib/module/context/RookSyncGateReducer.js.map +1 -1
- package/lib/module/context/RookSyncGateTypes.js +0 -2
- package/lib/module/context/index.js +2 -0
- package/lib/module/context/index.js.map +1 -0
- package/lib/module/hooks/index.js +11 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useRookAPISources.js +16 -10
- package/lib/module/hooks/useRookAPISources.js.map +1 -1
- package/lib/module/hooks/useRookAndroidBackgroundSteps.js +12 -11
- package/lib/module/hooks/useRookAndroidBackgroundSteps.js.map +1 -1
- package/lib/module/hooks/useRookAppleHealth.js +10 -9
- package/lib/module/hooks/useRookAppleHealth.js.map +1 -1
- package/lib/module/hooks/useRookConfiguration.js +34 -10
- package/lib/module/hooks/useRookConfiguration.js.map +1 -1
- package/lib/module/hooks/useRookData.js +45 -31
- package/lib/module/hooks/useRookData.js.map +1 -1
- package/lib/module/hooks/useRookHealthConnect.js +10 -9
- package/lib/module/hooks/useRookHealthConnect.js.map +1 -1
- package/lib/module/hooks/useRookPermissions.js +49 -26
- package/lib/module/hooks/useRookPermissions.js.map +1 -1
- package/lib/module/hooks/useRookSamsungHealth.js +20 -8
- package/lib/module/hooks/useRookSamsungHealth.js.map +1 -1
- package/lib/module/hooks/useRookSync.js +32 -23
- package/lib/module/hooks/useRookSync.js.map +1 -1
- package/lib/module/hooks/useRookVariables.js +37 -19
- package/lib/module/hooks/useRookVariables.js.map +1 -1
- package/lib/module/index.js +10 -18
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/hook/useRookAutoSync.js +40 -27
- package/lib/module/modules/hook/useRookAutoSync.js.map +1 -1
- package/lib/module/modules/types/sendMessageBroadcast.js +1 -1
- package/lib/module/modules/utils/errors.js +0 -2
- package/lib/module/modules/utils/errors.js.map +1 -1
- package/lib/module/types/ActivityEvent.js +0 -2
- package/lib/module/types/AppleHealthNutritionEvent.js +70 -0
- package/lib/module/types/AppleHealthNutritionEvent.js.map +1 -0
- package/lib/module/types/AppleHealthPermissions.js +0 -2
- package/lib/module/types/AppleHealthPermissions.js.map +1 -1
- package/lib/module/types/AuthorizedSources.js +0 -2
- package/lib/module/types/BodySummary.js +0 -2
- package/lib/module/types/DataSource.js +0 -2
- package/lib/module/types/DataSource.js.map +1 -1
- package/lib/module/types/DiagnosticState.js +2 -0
- package/lib/module/types/DiagnosticState.js.map +1 -0
- package/lib/module/types/HCMealData.js +59 -0
- package/lib/module/types/HCMealData.js.map +1 -0
- package/lib/module/types/HeartRateEvent.js +1 -1
- package/lib/module/types/PermissionsType.js +1 -1
- package/lib/module/types/PhysicalSummary.js +0 -2
- package/lib/module/types/SDKSources.js +0 -2
- package/lib/module/types/SDKSources.js.map +1 -1
- package/lib/module/types/SamsungHealthPermissions.js +0 -3
- package/lib/module/types/SamsungHealthPermissions.js.map +1 -1
- package/lib/module/types/SleepSummary.js +0 -2
- package/lib/module/types/SummaryTypes.js +1 -1
- package/lib/module/types/SyncTypes.js +0 -2
- package/lib/module/types/SyncTypes.js.map +1 -1
- package/lib/module/types/WriteNutrition.js +12 -0
- package/lib/module/types/WriteNutrition.js.map +1 -0
- package/lib/module/utils/getNativeModule.js +23 -0
- package/lib/module/utils/getNativeModule.js.map +1 -0
- package/lib/module/utils/getRookModule.js +22 -0
- package/lib/module/utils/getRookModule.js.map +1 -0
- package/lib/module/utils/isModuleReady.js +0 -2
- package/lib/module/utils/isModuleReady.js.map +1 -1
- package/lib/module/utils/isRunningOnAndroid.js +0 -2
- package/lib/module/utils/isRunningOnAndroid.js.map +1 -1
- package/lib/module/utils/isRunningOniOS.js +0 -2
- package/lib/module/utils/isRunningOniOS.js.map +1 -1
- package/lib/module/utils/isValidDate.js +20 -2
- package/lib/module/utils/isValidDate.js.map +1 -1
- package/lib/module/utils/nativeModules.js +23 -0
- package/lib/module/utils/nativeModules.js.map +1 -0
- package/lib/module/utils/packageInfo.js +7 -0
- package/lib/module/utils/packageInfo.js.map +1 -0
- package/lib/typescript/src/context/RookSyncGateContext.d.ts.map +1 -1
- package/lib/typescript/src/context/RookSyncGateProvider.d.ts.map +1 -1
- package/lib/typescript/src/context/RookSyncGateReducer.d.ts.map +1 -1
- package/lib/typescript/src/context/RookSyncGateTypes.d.ts +14 -4
- package/lib/typescript/src/context/RookSyncGateTypes.d.ts.map +1 -1
- package/lib/typescript/src/context/index.d.ts +2 -0
- package/lib/typescript/src/context/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +11 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useRookAPISources.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookAndroidBackgroundSteps.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookAppleHealth.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookConfiguration.d.ts +3 -1
- package/lib/typescript/src/hooks/useRookConfiguration.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookData.d.ts +2 -2
- package/lib/typescript/src/hooks/useRookData.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookHealthConnect.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookPermissions.d.ts +2 -0
- package/lib/typescript/src/hooks/useRookPermissions.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookSamsungHealth.d.ts +6 -0
- package/lib/typescript/src/hooks/useRookSamsungHealth.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookSync.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookVariables.d.ts +2 -0
- package/lib/typescript/src/hooks/useRookVariables.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +8 -17
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/modules/hook/useRookAutoSync.d.ts.map +1 -1
- package/lib/typescript/src/types/AppleHealthNutritionEvent.d.ts +76 -0
- package/lib/typescript/src/types/AppleHealthNutritionEvent.d.ts.map +1 -0
- package/lib/typescript/src/types/AuthorizedSources.d.ts +0 -11
- package/lib/typescript/src/types/AuthorizedSources.d.ts.map +1 -1
- package/lib/typescript/src/types/DiagnosticState.d.ts +13 -0
- package/lib/typescript/src/types/DiagnosticState.d.ts.map +1 -0
- package/lib/typescript/src/types/HCMealData.d.ts +60 -0
- package/lib/typescript/src/types/HCMealData.d.ts.map +1 -0
- package/lib/typescript/src/types/HeartRateEvent.d.ts +2 -2
- package/lib/typescript/src/types/HeartRateEvent.d.ts.map +1 -1
- package/lib/typescript/src/types/SamsungHealthPermissions.d.ts +0 -1
- package/lib/typescript/src/types/SamsungHealthPermissions.d.ts.map +1 -1
- package/lib/typescript/src/types/SyncTypes.d.ts +1 -5
- package/lib/typescript/src/types/SyncTypes.d.ts.map +1 -1
- package/lib/typescript/src/types/WriteNutrition.d.ts +61 -0
- package/lib/typescript/src/types/WriteNutrition.d.ts.map +1 -0
- package/lib/typescript/src/utils/getNativeModule.d.ts +10 -0
- package/lib/typescript/src/utils/getNativeModule.d.ts.map +1 -0
- package/lib/typescript/src/utils/getRookModule.d.ts +9 -0
- package/lib/typescript/src/utils/getRookModule.d.ts.map +1 -0
- package/lib/typescript/src/utils/isModuleReady.d.ts.map +1 -1
- package/lib/typescript/src/utils/isValidDate.d.ts +8 -0
- package/lib/typescript/src/utils/isValidDate.d.ts.map +1 -1
- package/lib/typescript/src/utils/nativeModules.d.ts +24 -0
- package/lib/typescript/src/utils/nativeModules.d.ts.map +1 -0
- package/lib/typescript/src/utils/packageInfo.d.ts +6 -0
- package/lib/typescript/src/utils/packageInfo.d.ts.map +1 -0
- package/package.json +98 -94
- package/react-native-rook-sdk.podspec +45 -0
- package/RNRookSdk.podspec +0 -22
- package/ios/Encodable.swift +0 -25
- package/ios/RookEntry.swift +0 -61
- package/ios/RookSdk-Bridging-Header.h +0 -12
- package/ios/boost-boost_privacy-Bridging-Header.h +0 -4
- package/lib/module/NativeRookSdk.js +0 -13
- package/lib/module/NativeRookSdk.js.map +0 -1
- package/lib/module/package.json +0 -1
- package/lib/module/types/Rook.js +0 -2
- package/lib/typescript/package.json +0 -1
- package/lib/typescript/src/NativeRookSdk.d.ts +0 -116
- package/lib/typescript/src/NativeRookSdk.d.ts.map +0 -1
- package/lib/typescript/src/types/Rook.d.ts +0 -9
- package/lib/typescript/src/types/Rook.d.ts.map +0 -1
- package/src/NativeRookSdk.ts +0 -274
- package/src/context/RookSyncGateProvider.tsx +0 -78
- package/src/context/RookSyncGateTypes.ts +0 -34
- package/src/hooks/useRookAndroidBackgroundSteps.ts +0 -81
- package/src/hooks/useRookAppleHealth.ts +0 -55
- package/src/hooks/useRookConfiguration.ts +0 -82
- package/src/hooks/useRookData.ts +0 -122
- package/src/hooks/useRookHealthConnect.ts +0 -59
- package/src/hooks/useRookPermissions.ts +0 -224
- package/src/hooks/useRookSamsungHealth.ts +0 -37
- package/src/hooks/useRookSync.ts +0 -157
- package/src/hooks/useRookVariables.ts +0 -77
- package/src/index.tsx +0 -28
- package/src/modules/hook/useRookAutoSync.ts +0 -305
- package/src/modules/types/sendMessageBroadcast.ts +0 -5
- package/src/modules/utils/errors.ts +0 -9
- package/src/types/ActivityEvent.ts +0 -159
- package/src/types/AppleHealthPermissions.ts +0 -49
- package/src/types/AuthorizedSources.ts +0 -33
- package/src/types/BodySummary.ts +0 -116
- package/src/types/DataSource.ts +0 -16
- package/src/types/HeartRateEvent.ts +0 -26
- package/src/types/PermissionsType.ts +0 -9
- package/src/types/PhysicalSummary.ts +0 -84
- package/src/types/Rook.ts +0 -8
- package/src/types/SDKSources.ts +0 -5
- package/src/types/SamsungHealthPermissions.ts +0 -16
- package/src/types/SleepSummary.ts +0 -66
- package/src/types/SummaryTypes.ts +0 -70
- package/src/types/SyncTypes.ts +0 -63
- package/src/utils/isRunningOnAndroid.ts +0 -10
- package/src/utils/isRunningOniOS.ts +0 -10
- package/src/utils/isValidDate.ts +0 -15
package/src/NativeRookSdk.ts
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import type { TurboModule, CodegenTypes } from 'react-native';
|
|
2
|
-
import { TurboModuleRegistry, NativeModules } from 'react-native';
|
|
3
|
-
|
|
4
|
-
type RookConfig = Readonly<{
|
|
5
|
-
environment: string;
|
|
6
|
-
clientUUID: string;
|
|
7
|
-
password: string;
|
|
8
|
-
enableLogs: boolean;
|
|
9
|
-
enableEventsBackgroundSync: boolean;
|
|
10
|
-
enableBackground: boolean;
|
|
11
|
-
}>;
|
|
12
|
-
|
|
13
|
-
type APIDataSource =
|
|
14
|
-
| 'Garmin'
|
|
15
|
-
| 'Oura'
|
|
16
|
-
| 'Polar'
|
|
17
|
-
| 'Fitbit'
|
|
18
|
-
| 'Withings'
|
|
19
|
-
| 'Whoop';
|
|
20
|
-
|
|
21
|
-
type DataSourceProps = Readonly<{
|
|
22
|
-
userID: string;
|
|
23
|
-
dataSource: APIDataSource;
|
|
24
|
-
redirectURL?: string;
|
|
25
|
-
}>;
|
|
26
|
-
|
|
27
|
-
type DataSourceAuthorizer = Readonly<{
|
|
28
|
-
dataSource: string;
|
|
29
|
-
authorized: boolean;
|
|
30
|
-
authorizationUrl?: string;
|
|
31
|
-
}>;
|
|
32
|
-
|
|
33
|
-
type AuthorizedSource = Readonly<{
|
|
34
|
-
name: string;
|
|
35
|
-
imageUrl: string;
|
|
36
|
-
authorized: boolean;
|
|
37
|
-
}>;
|
|
38
|
-
|
|
39
|
-
type SDKDataSource = 'HEALTH_CONNECT' | 'SAMSUNG_HEALTH' | 'APPLE_HEALTH';
|
|
40
|
-
|
|
41
|
-
type RequestStatusPermissions = 'REQUEST_SENT' | 'ALREADY_GRANTED';
|
|
42
|
-
|
|
43
|
-
type BackgroundStatus =
|
|
44
|
-
| 'UNAVAILABLE'
|
|
45
|
-
| 'PERMISSION_NOT_GRANTED'
|
|
46
|
-
| 'PERMISSION_GRANTED';
|
|
47
|
-
|
|
48
|
-
type CheckAvailabilityResponse =
|
|
49
|
-
| 'INSTALLED'
|
|
50
|
-
| 'NOT_INSTALLED'
|
|
51
|
-
| 'DISABLED'
|
|
52
|
-
| 'NOT_READY'
|
|
53
|
-
| 'OUTDATED'
|
|
54
|
-
| 'NOT_SUPPORTED';
|
|
55
|
-
|
|
56
|
-
type PermissionStatus =
|
|
57
|
-
| 'PERMISSION_NOT_REQUESTED'
|
|
58
|
-
| 'PERMISSION_INDETERMINATE'
|
|
59
|
-
| 'PERMISSION_GRANTED';
|
|
60
|
-
|
|
61
|
-
type SamsungHealthPermission =
|
|
62
|
-
| 'ACTIVITY_SUMMARY'
|
|
63
|
-
| 'BODY_TEMPERATURE'
|
|
64
|
-
| 'BLOOD_GLUCOSE'
|
|
65
|
-
| 'BLOOD_OXYGEN'
|
|
66
|
-
| 'BLOOD_PRESSURE'
|
|
67
|
-
| 'BODY_COMPOSITION'
|
|
68
|
-
| 'EXERCISE'
|
|
69
|
-
| 'EXERCISE_LOCATION'
|
|
70
|
-
| 'FLOORS_CLIMBED'
|
|
71
|
-
| 'HEART_RATE'
|
|
72
|
-
| 'NUTRITION'
|
|
73
|
-
| 'SLEEP'
|
|
74
|
-
| 'STEPS'
|
|
75
|
-
| 'WATER_INTAKE';
|
|
76
|
-
|
|
77
|
-
type AppleHealthPermission =
|
|
78
|
-
| 'appleExerciseTime'
|
|
79
|
-
| 'appleMoveTime'
|
|
80
|
-
| 'appleStandTime'
|
|
81
|
-
| 'basalEnergyBurned'
|
|
82
|
-
| 'activeEnergyBurned'
|
|
83
|
-
| 'stepCount'
|
|
84
|
-
| 'distanceCycling'
|
|
85
|
-
| 'distanceWalkingRunning'
|
|
86
|
-
| 'distanceSwimming'
|
|
87
|
-
| 'swimmingStrokeCount'
|
|
88
|
-
| 'flightsClimbed'
|
|
89
|
-
| 'walkingSpeed'
|
|
90
|
-
| 'walkingStepLength'
|
|
91
|
-
| 'runningPower'
|
|
92
|
-
| 'runningSpeed'
|
|
93
|
-
| 'height'
|
|
94
|
-
| 'bodyMass'
|
|
95
|
-
| 'bodyMassIndex'
|
|
96
|
-
| 'waistCircumference'
|
|
97
|
-
| 'bodyFatPercentage'
|
|
98
|
-
| 'bodyTemperature'
|
|
99
|
-
| 'basalBodyTemperature'
|
|
100
|
-
| 'appleSleepingWristTemperature'
|
|
101
|
-
| 'heartRate'
|
|
102
|
-
| 'restingHeartRate'
|
|
103
|
-
| 'walkingHeartRateAverage'
|
|
104
|
-
| 'heartRateVariabilitySDNN'
|
|
105
|
-
| 'electrocardiogram'
|
|
106
|
-
| 'workout'
|
|
107
|
-
| 'sleepAnalysis'
|
|
108
|
-
| 'vo2Max'
|
|
109
|
-
| 'oxygenSaturation'
|
|
110
|
-
| 'respiratoryRate'
|
|
111
|
-
| 'uvExposure'
|
|
112
|
-
| 'biologicalSex'
|
|
113
|
-
| 'dateOfBirth'
|
|
114
|
-
| 'bloodPressureSystolic'
|
|
115
|
-
| 'bloodPressureDiastolic'
|
|
116
|
-
| 'bloodGlucose'
|
|
117
|
-
| 'dietaryEnergyConsumed'
|
|
118
|
-
| 'dietaryProtein'
|
|
119
|
-
| 'dietarySugar'
|
|
120
|
-
| 'dietaryFatTotal'
|
|
121
|
-
| 'dietaryCarbohydrates'
|
|
122
|
-
| 'dietaryFiber'
|
|
123
|
-
| 'dietarySodium'
|
|
124
|
-
| 'dietaryCholesterol';
|
|
125
|
-
|
|
126
|
-
type Calories = Readonly<{
|
|
127
|
-
active: number;
|
|
128
|
-
basal: number;
|
|
129
|
-
}>;
|
|
130
|
-
|
|
131
|
-
type RookError = Readonly<{
|
|
132
|
-
code: string;
|
|
133
|
-
message: string;
|
|
134
|
-
}>;
|
|
135
|
-
|
|
136
|
-
type Message = Readonly<{
|
|
137
|
-
type: string;
|
|
138
|
-
value: boolean;
|
|
139
|
-
message?: string;
|
|
140
|
-
}>;
|
|
141
|
-
|
|
142
|
-
export interface Spec extends TurboModule {
|
|
143
|
-
initRook: (options: RookConfig) => Promise<boolean>;
|
|
144
|
-
|
|
145
|
-
// API Sources
|
|
146
|
-
revokeDataSource: (userid: string, type: APIDataSource) => Promise<boolean>;
|
|
147
|
-
getDataSourceAuthorizer: (
|
|
148
|
-
props: DataSourceProps
|
|
149
|
-
) => Promise<DataSourceAuthorizer>;
|
|
150
|
-
getAuthorizedDataSourcesV2: (userid: string) => Promise<AuthorizedSource[]>;
|
|
151
|
-
|
|
152
|
-
// Configuration
|
|
153
|
-
getUserID: () => Promise<string>;
|
|
154
|
-
updateUserID: (userID: string) => Promise<boolean>;
|
|
155
|
-
removeUserFromRook: (sources: SDKDataSource[]) => Promise<boolean>;
|
|
156
|
-
syncUserTimeZone: () => Promise<boolean>;
|
|
157
|
-
|
|
158
|
-
// bg android steps
|
|
159
|
-
isStepsAvailable: () => Promise<boolean>;
|
|
160
|
-
enableBackgroundAndroidSteps: () => Promise<boolean>;
|
|
161
|
-
disableBackgroundAndroidSteps: () => Promise<boolean>;
|
|
162
|
-
isBackgroundAndroidStepsActive: () => Promise<boolean>;
|
|
163
|
-
syncTodayAndroidStepsCount: () => Promise<string>;
|
|
164
|
-
syncTodayHealthConnectStepsCount: () => Promise<string>;
|
|
165
|
-
|
|
166
|
-
//Apple health hook
|
|
167
|
-
enableBackGroundUpdates: () => Promise<boolean>;
|
|
168
|
-
disableBackGroundUpdates: () => Promise<boolean>;
|
|
169
|
-
isBackgroundUpdatesEnabled: () => Promise<boolean>;
|
|
170
|
-
|
|
171
|
-
// Permissions
|
|
172
|
-
checkHealthConnectAvailability: () => Promise<CheckAvailabilityResponse>;
|
|
173
|
-
checkSamsungAvailability: () => Promise<CheckAvailabilityResponse>;
|
|
174
|
-
healthConnectHasPermissions: () => Promise<boolean>;
|
|
175
|
-
healthConnectHasPartialPermissions: () => Promise<boolean>;
|
|
176
|
-
appleHealthHasPermissions: (
|
|
177
|
-
param: AppleHealthPermission
|
|
178
|
-
) => Promise<PermissionStatus>;
|
|
179
|
-
samsungHealthHasPermissions: () => Promise<boolean>;
|
|
180
|
-
samsungHealthHasPartialPermissions: () => Promise<boolean>;
|
|
181
|
-
requestHealthConnectPermissions: () => Promise<RequestStatusPermissions>;
|
|
182
|
-
requestAppleHealthPermissions: (
|
|
183
|
-
permissions?: AppleHealthPermission[]
|
|
184
|
-
) => Promise<boolean>;
|
|
185
|
-
requestSamsungHealthPermissions: (
|
|
186
|
-
permissions?: SamsungHealthPermission[]
|
|
187
|
-
) => Promise<RequestStatusPermissions>;
|
|
188
|
-
openAppleHealthSettings: () => Promise<void>;
|
|
189
|
-
openHealthConnectSettings: () => Promise<void>;
|
|
190
|
-
requestAndroidBackgroundPermissions: () => Promise<RequestStatusPermissions>;
|
|
191
|
-
androidHasBackgroundPermissions: () => Promise<boolean>;
|
|
192
|
-
checkHealthConnectBackgroundReadStatus: () => Promise<BackgroundStatus>;
|
|
193
|
-
revokeHealthConnectPermissions: () => Promise<boolean>;
|
|
194
|
-
|
|
195
|
-
// Local data any in the response to avoid paste the complete object
|
|
196
|
-
getAppleHealthSleepSummary: (date: string) => Promise<any[]>;
|
|
197
|
-
getHealthConnectSleepSummary: (date: string) => Promise<string>;
|
|
198
|
-
getSamsungSleepSummary: (date: string) => Promise<string>;
|
|
199
|
-
|
|
200
|
-
getAppleHealthBodySummary: (date: string) => Promise<any>;
|
|
201
|
-
getHealthConnectBodySummary: (date: string) => Promise<string>;
|
|
202
|
-
getSamsungBodySummary: (date: string) => Promise<string>;
|
|
203
|
-
|
|
204
|
-
getAppleHealthPhysicalSummary: (date: string) => Promise<any>;
|
|
205
|
-
getHealthConnectPhysicalSummary: (date: string) => Promise<string>;
|
|
206
|
-
getSamsungPhysicalSummary: (date: string) => Promise<string>;
|
|
207
|
-
|
|
208
|
-
getAppleHealthActivityEvents: (date: string) => Promise<any[]>;
|
|
209
|
-
getHealthConnectActivityEvents: (date: string) => Promise<string>;
|
|
210
|
-
getSamsungActivityEvents: (date: string) => Promise<string>;
|
|
211
|
-
|
|
212
|
-
getTodayHeartRate: () => Promise<any>;
|
|
213
|
-
|
|
214
|
-
// samsung hook
|
|
215
|
-
enableSamsungSync: () => Promise<boolean>;
|
|
216
|
-
disableSamsungSync: () => Promise<boolean>;
|
|
217
|
-
isSamsungSyncEnabled: () => Promise<boolean>;
|
|
218
|
-
|
|
219
|
-
// health connect hook
|
|
220
|
-
scheduleBackgroundSync: (enableLogs: boolean) => Promise<boolean>;
|
|
221
|
-
cancelBackgroundSync: () => Promise<boolean>;
|
|
222
|
-
isBackgroundSyncEnabled: () => Promise<boolean>;
|
|
223
|
-
|
|
224
|
-
// variables
|
|
225
|
-
syncTodaySamsungHealthStepsCount: () => Promise<string>;
|
|
226
|
-
getTodayAppleHealthSteps: () => Promise<string>;
|
|
227
|
-
syncTodayCaloriesCount: () => Promise<Calories>;
|
|
228
|
-
syncSHTodayCaloriesCount: () => Promise<Calories>;
|
|
229
|
-
|
|
230
|
-
// sync
|
|
231
|
-
sync: (cb: (error: RookError, result: boolean) => void) => void;
|
|
232
|
-
syncByDate: (
|
|
233
|
-
date: string,
|
|
234
|
-
cb: (error: RookError, result: boolean) => void
|
|
235
|
-
) => void;
|
|
236
|
-
syncByDefinition: (
|
|
237
|
-
summary: string,
|
|
238
|
-
date: string,
|
|
239
|
-
cb: (error: RookError, result: boolean) => void
|
|
240
|
-
) => void;
|
|
241
|
-
syncEvent: (date: string, event: string) => Promise<any>;
|
|
242
|
-
|
|
243
|
-
shSync: (
|
|
244
|
-
enableLogs: boolean,
|
|
245
|
-
cb: (error: RookError, result: boolean) => void
|
|
246
|
-
) => void;
|
|
247
|
-
shSyncByDate: (
|
|
248
|
-
date: string,
|
|
249
|
-
cb: (error: RookError, result: boolean) => void
|
|
250
|
-
) => void;
|
|
251
|
-
shSyncByDefinition: (
|
|
252
|
-
summary: string,
|
|
253
|
-
date: string,
|
|
254
|
-
cb: (error: RookError, result: boolean) => void
|
|
255
|
-
) => void;
|
|
256
|
-
shSyncEvent: (date: string, event: string) => Promise<any>;
|
|
257
|
-
|
|
258
|
-
// Notifications
|
|
259
|
-
sendMessage: (message: Message) => Promise<boolean>;
|
|
260
|
-
readonly onRookMessage: CodegenTypes.EventEmitter<Message>;
|
|
261
|
-
}
|
|
262
|
-
const turboModule = TurboModuleRegistry.get<Spec>('RNRookSdk');
|
|
263
|
-
|
|
264
|
-
console.log({ exists: turboModule !== null });
|
|
265
|
-
|
|
266
|
-
const RookSdk = turboModule ? turboModule : NativeModules.RNRookSdk;
|
|
267
|
-
|
|
268
|
-
if (!RookSdk) {
|
|
269
|
-
throw new Error(
|
|
270
|
-
'RNRookSdk module not found. Ensure you have linked the library and rebuilt the app.'
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export default RookSdk;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
-
import { useReducer, type FC, useEffect } from 'react';
|
|
3
|
-
import { rookSyncGateReducer } from './RookSyncGateReducer'; // Importa el reducer
|
|
4
|
-
import type {
|
|
5
|
-
RookSyncGateState,
|
|
6
|
-
RookSyncGateProviderProps,
|
|
7
|
-
} from './RookSyncGateTypes';
|
|
8
|
-
import { RookSyncGateContext } from './RookSyncGateContext';
|
|
9
|
-
import RookSdk from '../NativeRookSdk';
|
|
10
|
-
import { useRookAutoSync } from '../modules/hook/useRookAutoSync';
|
|
11
|
-
|
|
12
|
-
const initialState: RookSyncGateState = {
|
|
13
|
-
clientUUID: '',
|
|
14
|
-
environment: 'sandbox',
|
|
15
|
-
password: '',
|
|
16
|
-
ready: false,
|
|
17
|
-
userID: '',
|
|
18
|
-
permissions: 0,
|
|
19
|
-
enableLogs: false,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/*
|
|
23
|
-
* This code snippet is defining a React functional component called `RookSyncGateProvider`.
|
|
24
|
-
* this define the provider for the SDK
|
|
25
|
-
*/
|
|
26
|
-
const RookSyncGateProvider: FC<RookSyncGateProviderProps> = ({
|
|
27
|
-
environment,
|
|
28
|
-
clientUUID,
|
|
29
|
-
password,
|
|
30
|
-
children,
|
|
31
|
-
enableLogs = false,
|
|
32
|
-
enableBackgroundSync,
|
|
33
|
-
enableEventsBackgroundSync = true,
|
|
34
|
-
}) => {
|
|
35
|
-
const [state, dispatch] = useReducer(rookSyncGateReducer, initialState);
|
|
36
|
-
|
|
37
|
-
const { startBackgroundServices } = useRookAutoSync({
|
|
38
|
-
state,
|
|
39
|
-
enableBackground: enableBackgroundSync,
|
|
40
|
-
enableLogs,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
initModule();
|
|
45
|
-
}, [environment, clientUUID, password]);
|
|
46
|
-
|
|
47
|
-
const initModule = async (): Promise<void> => {
|
|
48
|
-
dispatch({ type: 'SET_ROOK_ENVIRONMENT', environment });
|
|
49
|
-
dispatch({ type: 'SET_CLIENT_UUID', clientUUID });
|
|
50
|
-
dispatch({ type: 'SET_PASSWORD', password });
|
|
51
|
-
dispatch({ type: 'SET_ENABLE_LOGS', enableLogs });
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
await RookSdk.initRook({
|
|
55
|
-
environment,
|
|
56
|
-
clientUUID,
|
|
57
|
-
password,
|
|
58
|
-
enableLogs,
|
|
59
|
-
enableEventsBackgroundSync,
|
|
60
|
-
enableBackground: enableBackgroundSync,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
if (enableBackgroundSync) startBackgroundServices();
|
|
64
|
-
|
|
65
|
-
dispatch({ type: 'SET_READY', ready: true });
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.log(error);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<RookSyncGateContext.Provider value={{ state, dispatch }}>
|
|
73
|
-
{children}
|
|
74
|
-
</RookSyncGateContext.Provider>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export default RookSyncGateProvider;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
export type Environment = 'sandbox' | 'production';
|
|
4
|
-
|
|
5
|
-
type RookSyncGateState = {
|
|
6
|
-
clientUUID: string;
|
|
7
|
-
environment: Environment;
|
|
8
|
-
password: string;
|
|
9
|
-
ready: boolean;
|
|
10
|
-
userID: string;
|
|
11
|
-
permissions: number;
|
|
12
|
-
enableLogs: boolean;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type Action =
|
|
16
|
-
| { type: 'SET_CLIENT_UUID'; clientUUID: string }
|
|
17
|
-
| { type: 'SET_ENABLE_LOGS'; enableLogs: boolean }
|
|
18
|
-
| { type: 'SET_PASSWORD'; password: string }
|
|
19
|
-
| { type: 'SET_PERMISSIONS' }
|
|
20
|
-
| { type: 'SET_READY'; ready: boolean }
|
|
21
|
-
| { type: 'SET_ROOK_ENVIRONMENT'; environment: Environment }
|
|
22
|
-
| { type: 'SET_USER_ID'; userID: string };
|
|
23
|
-
|
|
24
|
-
type RookSyncGateProviderProps = {
|
|
25
|
-
children: ReactNode;
|
|
26
|
-
environment: Environment;
|
|
27
|
-
clientUUID: string;
|
|
28
|
-
password: string;
|
|
29
|
-
enableLogs?: boolean;
|
|
30
|
-
enableBackgroundSync: boolean;
|
|
31
|
-
enableEventsBackgroundSync?: boolean;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type { RookSyncGateState, Action, RookSyncGateProviderProps };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import RookSdk from '../NativeRookSdk';
|
|
2
|
-
import { useRookSyncGateContext } from '../context/RookSyncGateContext';
|
|
3
|
-
import { isModuleReady } from '../utils/isModuleReady';
|
|
4
|
-
import isRunningOnAndroid from '../utils/isRunningOnAndroid';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The `useRookAndroidBackgroundSteps` function provides various methods for managing and retrieving
|
|
8
|
-
* step count data on Android devices using the Rook module.
|
|
9
|
-
* @returns The `useRookAndroidBackgroundSteps` function returns a hook with the functions that allows the user to
|
|
10
|
-
* control de steps sync
|
|
11
|
-
*/
|
|
12
|
-
export const useRookAndroidBackgroundSteps = () => {
|
|
13
|
-
const {
|
|
14
|
-
state: { ready },
|
|
15
|
-
} = useRookSyncGateContext();
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The function `isStepsAvailable` checks if steps data is available.
|
|
19
|
-
* @returns The function `isStepsAvailable` is returning a promise that resolve in a boolean value.
|
|
20
|
-
*/
|
|
21
|
-
const isStepsAvailable = async (): Promise<boolean> => {
|
|
22
|
-
isRunningOnAndroid();
|
|
23
|
-
isModuleReady(ready);
|
|
24
|
-
|
|
25
|
-
return RookSdk.isStepsAvailable();
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The function `enableBackgroundAndroidSteps` starts collecting of steps during the day
|
|
30
|
-
* @returns The `enableBackgroundAndroidSteps` function is returning a Promise that resolves to a boolean
|
|
31
|
-
*/
|
|
32
|
-
const enableBackgroundAndroidSteps = async (): Promise<boolean> => {
|
|
33
|
-
isRunningOnAndroid();
|
|
34
|
-
isModuleReady(ready);
|
|
35
|
-
|
|
36
|
-
return RookSdk.enableBackgroundAndroidSteps();
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The function `disableBackgroundAndroidSteps` stops a process of collecting steps during the day
|
|
41
|
-
* @returns The function `disableBackgroundAndroidSteps` function is returning a Promise that resolves to a boolean
|
|
42
|
-
*/
|
|
43
|
-
const disableBackgroundAndroidSteps = (): Promise<boolean> => {
|
|
44
|
-
isRunningOnAndroid();
|
|
45
|
-
isModuleReady(ready);
|
|
46
|
-
|
|
47
|
-
return RookSdk.disableBackgroundAndroidSteps();
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* The function `isBackgroundAndroidStepsActive` checks if steps are active and returns a Promise with a boolean
|
|
52
|
-
* value.
|
|
53
|
-
* @returns The function is returning a Promise that resolves to a boolean
|
|
54
|
-
*/
|
|
55
|
-
const isBackgroundAndroidStepsActive = (): Promise<boolean> => {
|
|
56
|
-
isRunningOnAndroid();
|
|
57
|
-
isModuleReady(ready);
|
|
58
|
-
|
|
59
|
-
return RookSdk.isBackgroundAndroidStepsActive();
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The function `getTodayAndroidStepsCount` retrieves the number of steps taken today asynchronously as string.
|
|
64
|
-
* @returns The function `getTodaySteps` is returning the result of calling
|
|
65
|
-
*/
|
|
66
|
-
const syncTodayAndroidStepsCount = (): Promise<string> => {
|
|
67
|
-
isRunningOnAndroid();
|
|
68
|
-
isModuleReady(ready);
|
|
69
|
-
|
|
70
|
-
return RookSdk.syncTodayAndroidStepsCount();
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
ready,
|
|
75
|
-
isStepsAvailable,
|
|
76
|
-
enableBackgroundAndroidSteps,
|
|
77
|
-
disableBackgroundAndroidSteps,
|
|
78
|
-
isBackgroundAndroidStepsActive,
|
|
79
|
-
syncTodayAndroidStepsCount,
|
|
80
|
-
};
|
|
81
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import RookSdk from '../NativeRookSdk';
|
|
2
|
-
|
|
3
|
-
import { useRookSyncGateContext } from '../context/RookSyncGateContext';
|
|
4
|
-
import { isModuleReady } from '../utils/isModuleReady';
|
|
5
|
-
import { isRunningOniOS } from '../utils/isRunningOniOS';
|
|
6
|
-
|
|
7
|
-
export const useRookAppleHealth = () => {
|
|
8
|
-
const {
|
|
9
|
-
state: { ready },
|
|
10
|
-
} = useRookSyncGateContext();
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The function `enableBackGroundUpdates` enable background updates and returns a promise
|
|
14
|
-
* indicating success.
|
|
15
|
-
* @returns The function `enableBackGroundUpdates` returns a Promise that resolves to a boolean
|
|
16
|
-
* value.
|
|
17
|
-
*/
|
|
18
|
-
const enableBackGroundUpdates = (): Promise<boolean> => {
|
|
19
|
-
isRunningOniOS();
|
|
20
|
-
isModuleReady(ready);
|
|
21
|
-
|
|
22
|
-
return RookSdk.enableBackGroundUpdates();
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The function `disableBackGroundUpdates` disables background updates and returns a promise
|
|
27
|
-
* indicating success.
|
|
28
|
-
* @returns The function `disableBackGroundUpdates` returns a Promise that resolves to a boolean
|
|
29
|
-
* value.
|
|
30
|
-
*/
|
|
31
|
-
const disableBackGroundUpdates = (): Promise<boolean> => {
|
|
32
|
-
isRunningOniOS();
|
|
33
|
-
isModuleReady(ready);
|
|
34
|
-
|
|
35
|
-
return RookSdk.disableBackGroundUpdates();
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* This function checks if background summaries are enabled.
|
|
40
|
-
* @returns The function `isBackGroundForSummariesEnable` is returning a boolean value
|
|
41
|
-
*/
|
|
42
|
-
const isBackgroundUpdatesEnabled = async (): Promise<boolean> => {
|
|
43
|
-
isRunningOniOS();
|
|
44
|
-
isModuleReady(ready);
|
|
45
|
-
|
|
46
|
-
return RookSdk.isBackgroundUpdatesEnabled();
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
ready,
|
|
51
|
-
enableBackGroundUpdates,
|
|
52
|
-
disableBackGroundUpdates,
|
|
53
|
-
isBackgroundUpdatesEnabled,
|
|
54
|
-
};
|
|
55
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import RookSdk from '../NativeRookSdk';
|
|
2
|
-
|
|
3
|
-
import { useRookSyncGateContext } from '../context/RookSyncGateContext';
|
|
4
|
-
import { isModuleReady } from '../utils/isModuleReady';
|
|
5
|
-
import { type SDKDataSource } from '../types/SDKSources';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The `useRookConfiguration` hook provides various asynchronous methods for managing the configuration
|
|
9
|
-
* of the ROOK SDK
|
|
10
|
-
* @returns The `useRookConfiguration` function returns an object containing that allow the user to configure
|
|
11
|
-
* the SDK
|
|
12
|
-
*/
|
|
13
|
-
export const useRookConfiguration = () => {
|
|
14
|
-
const {
|
|
15
|
-
state: { ready },
|
|
16
|
-
dispatch,
|
|
17
|
-
} = useRookSyncGateContext();
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The `getUserID` function retrieves the user ID
|
|
21
|
-
* @returns The function `getUserID` is returning a Promise that resolves to a string value.
|
|
22
|
-
*/
|
|
23
|
-
const getUserID = async (): Promise<string> => {
|
|
24
|
-
isModuleReady(ready);
|
|
25
|
-
|
|
26
|
-
const result = await RookSdk.getUserID();
|
|
27
|
-
|
|
28
|
-
if (result) dispatch({ type: 'SET_USER_ID', userID: result });
|
|
29
|
-
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The function `updateUserID` updates the user ID and returns a boolean indicating the success of
|
|
35
|
-
* the update.
|
|
36
|
-
* @param {string} userID - The `userID` parameter is a string that represents the user ID that needs
|
|
37
|
-
* to be updated in the system.
|
|
38
|
-
* @returns The `updateUserID` function returns a Promise that resolves to a boolean value.
|
|
39
|
-
*/
|
|
40
|
-
const updateUserID = async (userID: string): Promise<boolean> => {
|
|
41
|
-
isModuleReady(ready);
|
|
42
|
-
|
|
43
|
-
const result: boolean = await RookSdk.updateUserID(userID);
|
|
44
|
-
|
|
45
|
-
dispatch({ type: 'SET_USER_ID', userID });
|
|
46
|
-
|
|
47
|
-
return result;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* This function `syncUserTimeZone` synchronizes the user's time zone using
|
|
52
|
-
* @returns The `syncUserTimeZone` function returns a boolean value, indicating success or failure
|
|
53
|
-
*/
|
|
54
|
-
const syncUserTimeZone = async (): Promise<boolean> => {
|
|
55
|
-
isModuleReady(ready);
|
|
56
|
-
|
|
57
|
-
const result: boolean = await RookSdk.syncUserTimeZone();
|
|
58
|
-
return result;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* The function `removeUserFromRook` removes a user from a rook services, If you delete the user from the Rook services you have to create the user again with updateUserID and request permissions.
|
|
63
|
-
* @returns The `removeUserFromRook` function is returning a boolean value.
|
|
64
|
-
*/
|
|
65
|
-
const removeUserFromRook = async (
|
|
66
|
-
sources: SDKDataSource[]
|
|
67
|
-
): Promise<boolean> => {
|
|
68
|
-
isModuleReady(ready);
|
|
69
|
-
|
|
70
|
-
dispatch({ type: 'SET_USER_ID', userID: '' });
|
|
71
|
-
|
|
72
|
-
return RookSdk.removeUserFromRook(sources);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
ready,
|
|
77
|
-
getUserID,
|
|
78
|
-
updateUserID,
|
|
79
|
-
removeUserFromRook,
|
|
80
|
-
syncUserTimeZone,
|
|
81
|
-
};
|
|
82
|
-
};
|