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/ios/RookSdk.mm
CHANGED
|
@@ -1,399 +1,48 @@
|
|
|
1
1
|
#import "RookSdk.h"
|
|
2
|
-
#import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
RookSync *sync;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
- (id) init {
|
|
16
|
-
if (self = [super init]) {
|
|
17
|
-
sources = [RookSources new];
|
|
18
|
-
entry = [RookEntry new];
|
|
19
|
-
config = [RookConfiguration new];
|
|
20
|
-
bg = [RookBackground new];
|
|
21
|
-
perm = [RookPermissions new];
|
|
22
|
-
data = [RookData new];
|
|
23
|
-
sync = [RookSync new];
|
|
24
|
-
shouldEmitEvent = NO;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return self;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// --- TURBOMODULE (New Arch) ---
|
|
31
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
32
|
-
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
33
|
-
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
34
|
-
{
|
|
35
|
-
return std::make_shared<facebook::react::NativeRookSdkSpecJSI>(params);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
+ (NSString *)moduleName
|
|
39
|
-
{
|
|
40
|
-
return @"RNRookSdk";
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
- (void)initialize {
|
|
44
|
-
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
45
|
-
selector:@selector(handleErrorBackground:)
|
|
46
|
-
name:entry.EVENT_NAME
|
|
47
|
-
object:nil];
|
|
48
|
-
shouldEmitEvent = YES;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
- (void)handleErrorBackground:(NSNotification *)notification {
|
|
52
|
-
NSDictionary *data = notification.userInfo;
|
|
53
|
-
|
|
54
|
-
if (data) {
|
|
55
|
-
NSError *error = data[@"Error"];
|
|
56
|
-
|
|
57
|
-
[self emitOnRookMessage:@{
|
|
58
|
-
@"type": @"ROOK_BACKGROUND_IOS_ERROR",
|
|
59
|
-
@"value": @(NO),
|
|
60
|
-
@"message": error ? error.localizedDescription : @"An error occurred in the iOS background process"
|
|
61
|
-
}];
|
|
2
|
+
#import <React/RCTLog.h>
|
|
3
|
+
#import "RookSDK/RookSDK-Swift.h"
|
|
4
|
+
#import "RCTConvert.h"
|
|
5
|
+
|
|
6
|
+
// MARK: - Utils
|
|
7
|
+
NSString *convertToString(id value) {
|
|
8
|
+
if ([value isKindOfClass:[NSString class]]) {
|
|
9
|
+
return (NSString *)value;
|
|
10
|
+
} else {
|
|
11
|
+
return [value description];
|
|
62
12
|
}
|
|
63
13
|
}
|
|
64
14
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
reject(@"1001", @"This method is only available in android", nil);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
- (void)isNotiOSCBSupported: (nonnull RCTResponseSenderBlock)cb {
|
|
75
|
-
NSDictionary *errorInfo = @{
|
|
76
|
-
@"code": @"1001",
|
|
77
|
-
@"message": @"An error ocurred with SDK try again"
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
cb(@[errorInfo, @NO]);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
- (void)syncSHTodayCaloriesCount:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
84
|
-
[self isNotiOSSupported:reject];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
- (void)syncTodaySamsungHealthStepsCount:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
88
|
-
[self isNotiOSSupported:reject];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
- (void)cancelBackgroundSync:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
92
|
-
[self isNotiOSSupported:reject];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
- (void)isBackgroundSyncEnabled:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
96
|
-
[self isNotiOSSupported:reject];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
- (void)scheduleBackgroundSync:(BOOL)enableLogs resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
100
|
-
[self isNotiOSSupported:reject];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
- (void)getHealthConnectActivityEvents:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
104
|
-
[self isNotiOSSupported:reject];
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
- (void)getHealthConnectBodySummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
109
|
-
[self isNotiOSSupported:reject];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
- (void)getHealthConnectPhysicalSummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
114
|
-
[self isNotiOSSupported:reject];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
- (void)getHealthConnectSleepSummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
119
|
-
[self isNotiOSSupported:reject];
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
- (void)getSamsungActivityEvents:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
124
|
-
[self isNotiOSSupported:reject];
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
- (void)getSamsungBodySummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
129
|
-
[self isNotiOSSupported:reject];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
- (void)getSamsungPhysicalSummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
134
|
-
[self isNotiOSSupported:reject];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
- (void)getSamsungSleepSummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
139
|
-
[self isNotiOSSupported:reject];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
- (void)disableSamsungSync:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
143
|
-
[self isNotiOSSupported:reject];
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
- (void)enableSamsungSync:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
147
|
-
[self isNotiOSSupported:reject];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
- (void)isSamsungSyncEnabled:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
151
|
-
[self isNotiOSSupported:reject];
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
- (void)disableBackgroundAndroidSteps:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
155
|
-
[self isNotiOSSupported:reject];
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
- (void)enableBackgroundAndroidSteps:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
159
|
-
[self isNotiOSSupported:reject];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
- (void)isBackgroundAndroidStepsActive:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
163
|
-
[self isNotiOSSupported:reject];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
- (void)isStepsAvailable:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
167
|
-
[self isNotiOSSupported:reject];
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
- (void)syncTodayAndroidStepsCount:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
171
|
-
[self isNotiOSSupported:reject];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
- (void)syncTodayHealthConnectStepsCount:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
175
|
-
[self isNotiOSSupported:reject];
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
- (void)androidHasBackgroundPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
179
|
-
[self isNotiOSSupported:reject];
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
- (void)checkHealthConnectAvailability:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
183
|
-
[self isNotiOSSupported:reject];
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
- (void)checkHealthConnectBackgroundReadStatus:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
187
|
-
[self isNotiOSSupported:reject];
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
- (void)checkSamsungAvailability:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
191
|
-
[self isNotiOSSupported:reject];
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
- (void)healthConnectHasPartialPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
195
|
-
[self isNotiOSSupported:reject];
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
- (void)healthConnectHasPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
199
|
-
[self isNotiOSSupported:reject];
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
- (void)openHealthConnectSettings:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
203
|
-
[self isNotiOSSupported:reject];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
- (void)requestAndroidBackgroundPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
207
|
-
[self isNotiOSSupported:reject];
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
- (void)requestHealthConnectPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
211
|
-
[self isNotiOSSupported:reject];
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
- (void)requestSamsungHealthPermissions:(nonnull NSArray *)permissions resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
215
|
-
[self isNotiOSSupported:reject];
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
- (void)revokeHealthConnectPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
220
|
-
[self isNotiOSSupported:reject];
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
- (void)samsungHealthHasPartialPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
225
|
-
[self isNotiOSSupported:reject];
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
- (void)samsungHealthHasPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
230
|
-
[self isNotiOSSupported:reject];
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
- (void)shSync:(BOOL)enableLogs cb:(nonnull RCTResponseSenderBlock)cb {
|
|
234
|
-
[self isNotiOSCBSupported:cb];
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
- (void)shSyncByDate:(nonnull NSString *)date cb:(nonnull RCTResponseSenderBlock)cb {
|
|
239
|
-
[self isNotiOSCBSupported:cb];
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
- (void)shSyncByDefinition:(nonnull NSString *)summary date:(nonnull NSString *)date cb:(nonnull RCTResponseSenderBlock)cb {
|
|
244
|
-
[self isNotiOSCBSupported:cb];
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
- (void)shSyncEvent:(nonnull NSString *)date event:(nonnull NSString *)event resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
249
|
-
[self isNotiOSSupported:reject];
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
- (void)getAuthorizedDataSourcesV2:(nonnull NSString *)userid resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
253
|
-
[sources getAuthorizedDataSourcesV2:userid resolve:resolve reject:reject];
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
- (void)getDataSourceAuthorizer:(JS::NativeRookSdk::DataSourceProps &)props resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
257
|
-
|
|
258
|
-
NSMutableDictionary *dict = [NSMutableDictionary new];
|
|
259
|
-
dict[@"dataSource"] = props.dataSource();
|
|
260
|
-
dict[@"redirectURL"] = props.redirectURL();
|
|
261
|
-
dict[@"userID"] = props.userID();
|
|
262
|
-
|
|
263
|
-
[sources getDataSourceAuthorizer:dict resolve:resolve reject:reject];
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
- (void)initRook:(JS::NativeRookSdk::RookConfig &)options resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
267
|
-
NSMutableDictionary *dict = [NSMutableDictionary new];
|
|
268
|
-
dict[@"password"] = options.password();
|
|
269
|
-
dict[@"environment"] = options.environment();
|
|
270
|
-
dict[@"clientUUID"] = options.clientUUID();
|
|
271
|
-
dict[@"enableBackground"] = @(options.enableBackground());
|
|
272
|
-
dict[@"enableEventsBackgroundSync"] = @(options.enableEventsBackgroundSync());
|
|
273
|
-
|
|
274
|
-
[entry initRook:dict resolve:resolve reject:reject];
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
- (void)revokeDataSource:(nonnull NSString *)userid type:(nonnull NSString *)type resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
278
|
-
[sources revokeDataSource:userid source:type resolve:resolve reject:reject];
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
- (void)getUserID:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
282
|
-
[config getUserID:resolve reject:reject];
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
- (void)removeUserFromRook:(nonnull NSArray *)sources resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
287
|
-
[config removeUserFromRook:resolve reject:reject];
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
- (void)syncUserTimeZone:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
292
|
-
[config syncUserTimeZone:resolve reject:reject];
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
- (void)updateUserID:(nonnull NSString *)userID resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
297
|
-
[config updateUserID:userID resolve:resolve reject:reject];
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
- (void)disableBackGroundUpdates:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
301
|
-
[bg disableBackGroundUpdates:resolve reject:reject];
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
- (void)enableBackGroundUpdates:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
306
|
-
[bg enableBackGroundUpdates:resolve reject:reject];
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
- (void)isBackgroundUpdatesEnabled:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
311
|
-
[bg isBackgroundUpdatesEnabled:resolve reject:reject];
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
- (void)appleHealthHasPermissions:(nonnull NSString *)param resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
315
|
-
[perm checkPermissionsStatus:param resolve:resolve reject:reject];
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
- (void)openAppleHealthSettings:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
319
|
-
[perm openAppleHealthSettings:resolve reject:reject];
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
- (void)requestAppleHealthPermissions:(nonnull NSArray *)permissions resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
323
|
-
[perm requestAppleHealthPermissions:permissions resolve:resolve reject:reject];
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
- (void)getAppleHealthActivityEvents:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
327
|
-
[data getAppleHealthActivityEvents:date resolve:resolve reject:reject];
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
- (void)getAppleHealthBodySummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
332
|
-
[data getAppleHealthBodySummary:date resolve:resolve reject:reject];
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
- (void)getAppleHealthPhysicalSummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
337
|
-
[data getAppleHealthPhysicalSummary:date resolve:resolve reject:reject];
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
- (void)getAppleHealthSleepSummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
342
|
-
[data getAppleHealthSleepSummary:date resolve:resolve reject:reject];
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
- (void)getTodayHeartRate:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
346
|
-
[data getTodayHeartRate:resolve reject:reject];
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
- (void)getTodayAppleHealthSteps:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
350
|
-
[sync getTodayAppleHealthSteps:resolve reject:reject];
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
- (void)syncTodayCaloriesCount:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
354
|
-
[sync syncTodayCaloriesCount:resolve reject:reject];
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
- (void)sync:(nonnull RCTResponseSenderBlock)cb {
|
|
358
|
-
[sync sync:cb];
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
- (void)syncByDate:(nonnull NSString *)date cb:(nonnull RCTResponseSenderBlock)cb {
|
|
363
|
-
[sync syncByDate:date callback:cb];
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
- (void)syncByDefinition:(nonnull NSString *)summary date:(nonnull NSString *)date cb:(nonnull RCTResponseSenderBlock)cb {
|
|
368
|
-
[sync syncByDefinition:summary syncDate:date callback:cb];
|
|
15
|
+
NSString * _Nullable tryConvertToString(id _Nullable value) {
|
|
16
|
+
if ([value isKindOfClass:[NSString class]]) {
|
|
17
|
+
return (NSString *)value;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return nil;
|
|
369
21
|
}
|
|
370
22
|
|
|
23
|
+
// A function that takes an NSException object as input and creates an
|
|
24
|
+
// NSError object based on the exception information. It creates a dictionary with localized
|
|
25
|
+
// description and failure reason keys using the exception's name and reason properties. Then, it
|
|
26
|
+
// creates an NSError object with a custom domain, error code, and the dictionary of error information,
|
|
27
|
+
// and returns it.
|
|
28
|
+
NSError *errorFromException(NSException *exception) {
|
|
29
|
+
NSMutableDictionary *errorInfo = [NSMutableDictionary dictionary];
|
|
30
|
+
errorInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"Exception caught: %@", exception.name];
|
|
31
|
+
errorInfo[NSLocalizedFailureReasonErrorKey] = exception.reason;
|
|
371
32
|
|
|
372
|
-
|
|
373
|
-
[sync syncEvent:date event:event resolve:resolve reject:reject];
|
|
33
|
+
return [NSError errorWithDomain:@"com.mydomain.MyApp" code:500 userInfo:errorInfo];
|
|
374
34
|
}
|
|
375
35
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
messageInfo[@"type"] = message.type();
|
|
381
|
-
messageInfo[@"value"] = @(message.value());
|
|
382
|
-
|
|
383
|
-
if (message.message().length > 0) {
|
|
384
|
-
messageInfo[@"message"] = message.message();
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
[self emitOnRookMessage:messageInfo];
|
|
388
|
-
}
|
|
36
|
+
// MARK: - Module
|
|
37
|
+
@implementation RookSdk
|
|
38
|
+
{
|
|
39
|
+
bool hasListeners;
|
|
389
40
|
}
|
|
390
41
|
|
|
391
|
-
#else
|
|
392
|
-
// --- BRIDGE (Old Arch) ---
|
|
393
42
|
RCT_EXPORT_MODULE()
|
|
394
43
|
|
|
395
44
|
-(void)startObserving {
|
|
396
|
-
|
|
45
|
+
hasListeners = YES;
|
|
397
46
|
|
|
398
47
|
NSLog(@"Hay alguien escuchando");
|
|
399
48
|
|
|
@@ -405,7 +54,7 @@ RCT_EXPORT_MODULE()
|
|
|
405
54
|
|
|
406
55
|
// Will be called when this module's last listener is removed, or on dealloc.
|
|
407
56
|
-(void)stopObserving {
|
|
408
|
-
|
|
57
|
+
hasListeners = NO;
|
|
409
58
|
|
|
410
59
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
411
60
|
}
|
|
@@ -429,188 +78,90 @@ RCT_EXPORT_MODULE()
|
|
|
429
78
|
message[@"message"] = notificationInfo[@"Error"].localizedDescription;
|
|
430
79
|
message[@"code"] = notificationInfo[@"Error"].description;
|
|
431
80
|
|
|
432
|
-
if (
|
|
81
|
+
if (hasListeners)
|
|
433
82
|
[self sendEventWithName:@"ROOK_NOTIFICATION" body: message];
|
|
434
83
|
}
|
|
435
84
|
}
|
|
436
85
|
|
|
86
|
+
RookConnectConfigurationManagerObjc *shared;
|
|
87
|
+
|
|
88
|
+
// MARK: - Configuration
|
|
89
|
+
/**
|
|
90
|
+
* Initializes the Rook SDK with the provided configuration.
|
|
91
|
+
*
|
|
92
|
+
* @param data A dictionary containing the configuration parameters:
|
|
93
|
+
* - clientUUID: The unique identifier for the client.
|
|
94
|
+
* - password: The client's secret key.
|
|
95
|
+
* - enableEventsBackgroundSync: A boolean indicating whether to enable background sync for events.
|
|
96
|
+
* - environment: The environment in which the SDK is running (production, sandbox, or development).
|
|
97
|
+
* - enableLogs: A boolean indicating whether console logs should be enabled.
|
|
98
|
+
* @param resolve A block called upon successful initialization.
|
|
99
|
+
* @param reject A block called if an error occurs during initialization.
|
|
100
|
+
*/
|
|
437
101
|
RCT_EXPORT_METHOD(initRook:(NSDictionary *) data
|
|
438
102
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
439
103
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
440
104
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
105
|
+
bool enableBackground = [RCTConvert BOOL:data[@"enableBackground"]];
|
|
106
|
+
|
|
107
|
+
shared = [RookConnectConfigurationManagerObjc shared];
|
|
108
|
+
[shared setConfigurationWithClientUUID:convertToString(data[@"clientUUID"])
|
|
109
|
+
secret:convertToString(data[@"secret"])
|
|
110
|
+
bundleId:tryConvertToString(data[@"bundleId"])
|
|
111
|
+
enableBackgroundSync:enableBackground
|
|
112
|
+
enableEventsBackgroundSync:enableBackground];
|
|
113
|
+
|
|
114
|
+
NSString *environment = convertToString(data[@"environment"]);
|
|
115
|
+
BOOL enableLogs = [RCTConvert BOOL:data[@"enableLogs"]];
|
|
116
|
+
|
|
117
|
+
NSDictionary *opcionActions = @{
|
|
118
|
+
@"production": ^{
|
|
119
|
+
[shared setEnvironmentForProduction];
|
|
120
|
+
[[IOSClass shared] disableTest];
|
|
121
|
+
},
|
|
122
|
+
@"sandbox": ^{
|
|
123
|
+
[shared setEnvironmentForSandbox];
|
|
124
|
+
[[IOSClass shared] disableTest];
|
|
125
|
+
},
|
|
126
|
+
@"development": ^{
|
|
127
|
+
[[IOSClass shared] test];
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
void (^selectAction)(void) = opcionActions[environment];
|
|
132
|
+
if (selectAction) selectAction();
|
|
133
|
+
|
|
134
|
+
[[AnalyticsExtractionConfigurator shared] setPlatformToReact];
|
|
135
|
+
[shared setConsoleLogAvailable: enableLogs];
|
|
136
|
+
[shared initRookWithCompletion:^(BOOL result, NSError * _Nullable error) {
|
|
137
|
+
if (error != nil) {
|
|
138
|
+
reject(@"1", error.localizedDescription, error);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
resolve(@(result));
|
|
144
|
+
}];
|
|
145
|
+
|
|
449
146
|
}
|
|
450
147
|
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
// MARK: - RN Broadcast
|
|
151
|
+
|
|
451
152
|
/**
|
|
452
|
-
* Internal method to send messages to broadcast channel
|
|
153
|
+
* Internal method to send messages to broadcast channel
|
|
453
154
|
*
|
|
454
155
|
* @param resolve A block called with a boolean value indicating whether the result is.
|
|
455
156
|
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
456
157
|
*/
|
|
457
|
-
RCT_EXPORT_METHOD(
|
|
158
|
+
RCT_EXPORT_METHOD(sendMessageToBroadcast: (NSDictionary *) message
|
|
458
159
|
resolve: (RCTPromiseResolveBlock) resolve
|
|
459
160
|
reject: (RCTPromiseRejectBlock) reject) {
|
|
460
|
-
if(
|
|
161
|
+
if(hasListeners) {
|
|
461
162
|
[self sendEventWithName:@"ROOK_NOTIFICATION" body:message];
|
|
462
163
|
}
|
|
463
164
|
}
|
|
165
|
+
@end
|
|
464
166
|
|
|
465
|
-
RCT_EXPORT_METHOD(getDataSourceAuthorizer:(NSDictionary *)props
|
|
466
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
467
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
468
|
-
[sources getDataSourceAuthorizer:props resolve:resolve reject:reject];
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
RCT_EXPORT_METHOD(revokeDataSource:(NSString *)userid
|
|
472
|
-
type:(NSString *)type
|
|
473
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
474
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
475
|
-
{
|
|
476
|
-
[sources revokeDataSource:userid source:type resolve:resolve reject:reject];
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
RCT_EXPORT_METHOD(getUserID:(RCTPromiseResolveBlock)resolve
|
|
480
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
481
|
-
{
|
|
482
|
-
[config getUserID:resolve reject:reject];
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
RCT_EXPORT_METHOD(removeUserFromRook:(NSArray *)sources
|
|
486
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
487
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
488
|
-
{
|
|
489
|
-
[config removeUserFromRook:resolve reject:reject];
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
RCT_EXPORT_METHOD(syncUserTimeZone:(RCTPromiseResolveBlock)resolve
|
|
493
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
494
|
-
{
|
|
495
|
-
[config syncUserTimeZone:resolve reject:reject];
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
RCT_EXPORT_METHOD(updateUserID:(NSString *)userID
|
|
499
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
500
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
501
|
-
{
|
|
502
|
-
[config updateUserID:userID resolve:resolve reject:reject];
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
RCT_EXPORT_METHOD(disableBackGroundUpdates:(RCTPromiseResolveBlock)resolve
|
|
506
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
507
|
-
{
|
|
508
|
-
[bg disableBackGroundUpdates:resolve reject:reject];
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
RCT_EXPORT_METHOD(enableBackGroundUpdates:(RCTPromiseResolveBlock)resolve
|
|
512
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
513
|
-
{
|
|
514
|
-
[bg enableBackGroundUpdates:resolve reject:reject];
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
RCT_EXPORT_METHOD(isBackgroundUpdatesEnabled:(RCTPromiseResolveBlock)resolve
|
|
518
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
519
|
-
{
|
|
520
|
-
[bg isBackgroundUpdatesEnabled:resolve reject:reject];
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
RCT_EXPORT_METHOD(appleHealthHasPermissions:(NSString *)param
|
|
524
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
525
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
526
|
-
{
|
|
527
|
-
[perm checkPermissionsStatus:param resolve:resolve reject:reject];
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
RCT_EXPORT_METHOD(openAppleHealthSettings:(RCTPromiseResolveBlock)resolve
|
|
531
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
532
|
-
{
|
|
533
|
-
[perm openAppleHealthSettings:resolve reject:reject];
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
RCT_EXPORT_METHOD(requestAppleHealthPermissions:(NSArray *)permissions
|
|
537
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
538
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
539
|
-
{
|
|
540
|
-
[perm requestAppleHealthPermissions:permissions resolve:resolve reject:reject];
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
RCT_EXPORT_METHOD(getAppleHealthActivityEvents:(NSString *)date
|
|
544
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
545
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
546
|
-
{
|
|
547
|
-
[data getAppleHealthActivityEvents:date resolve:resolve reject:reject];
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
RCT_EXPORT_METHOD(getAppleHealthBodySummary:(NSString *)date
|
|
551
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
552
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
553
|
-
{
|
|
554
|
-
[data getAppleHealthBodySummary:date resolve:resolve reject:reject];
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
RCT_EXPORT_METHOD(getAppleHealthPhysicalSummary:(NSString *)date
|
|
558
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
559
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
560
|
-
{
|
|
561
|
-
[data getAppleHealthPhysicalSummary:date resolve:resolve reject:reject];
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
RCT_EXPORT_METHOD(getAppleHealthSleepSummary:(NSString *)date
|
|
565
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
566
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
567
|
-
{
|
|
568
|
-
[data getAppleHealthSleepSummary:date resolve:resolve reject:reject];
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
RCT_EXPORT_METHOD(getTodayHeartRate:(RCTPromiseResolveBlock)resolve
|
|
572
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
573
|
-
{
|
|
574
|
-
[data getTodayHeartRate:resolve reject:reject];
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
RCT_EXPORT_METHOD(getTodayAppleHealthSteps:(RCTPromiseResolveBlock)resolve
|
|
578
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
579
|
-
{
|
|
580
|
-
[sync getTodayAppleHealthSteps:resolve reject:reject];
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
RCT_EXPORT_METHOD(syncTodayCaloriesCount:(RCTPromiseResolveBlock)resolve
|
|
584
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
585
|
-
{
|
|
586
|
-
[sync syncTodayCaloriesCount:resolve reject:reject];
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
RCT_EXPORT_METHOD(sync:(RCTResponseSenderBlock)cb)
|
|
590
|
-
{
|
|
591
|
-
[sync sync:cb];
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
RCT_EXPORT_METHOD(syncByDate:(NSString *)date
|
|
595
|
-
cb:(RCTResponseSenderBlock)cb)
|
|
596
|
-
{
|
|
597
|
-
[sync syncByDate:date callback:cb];
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
RCT_EXPORT_METHOD(syncByDefinition:(NSString *)summary
|
|
601
|
-
date:(NSString *)date
|
|
602
|
-
cb:(RCTResponseSenderBlock)cb)
|
|
603
|
-
{
|
|
604
|
-
[sync syncByDefinition:summary syncDate:date callback:cb];
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
RCT_EXPORT_METHOD(syncEvent:(NSString *)date
|
|
608
|
-
event:(NSString *)event
|
|
609
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
610
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
611
|
-
{
|
|
612
|
-
[sync syncEvent:date event:event resolve:resolve reject:reject];
|
|
613
|
-
}
|
|
614
|
-
#endif
|
|
615
167
|
|
|
616
|
-
@end
|