react-native-rook-sdk 2.1.1 → 4.0.0-beta.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 +35 -3
- package/RNRookSdk.podspec +22 -0
- package/android/build.gradle +20 -41
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/rooksdk/RookSdkModule.kt +11 -222
- package/android/src/main/java/com/rooksdk/RookSdkPackage.kt +24 -33
- package/ios/DateHelper.swift +55 -0
- package/ios/Encodable.swift +25 -0
- package/ios/EncodableDataSource.swift +5 -6
- package/ios/EncodableDataSourceAuthorizer.swift +4 -5
- package/ios/HearRateMapper.swift +42 -0
- package/ios/RookBackground.swift +35 -0
- package/ios/RookConfiguration.swift +116 -0
- package/ios/RookData.swift +170 -0
- package/ios/RookEntry.swift +61 -0
- package/ios/RookPermissions.swift +78 -0
- package/ios/RookSdk-Bridging-Header.h +12 -0
- package/ios/RookSdk.h +14 -2
- package/ios/RookSdk.mm +549 -81
- package/ios/RookSources.swift +74 -116
- package/ios/RookSync.swift +126 -34
- package/ios/boost-boost_privacy-Bridging-Header.h +4 -0
- package/lib/module/NativeRookSdk.js +96 -0
- package/lib/module/NativeRookSdk.js.map +1 -0
- package/lib/module/context/RookSyncGateContext.js +2 -0
- package/lib/module/context/RookSyncGateContext.js.map +1 -1
- package/lib/module/context/RookSyncGateProvider.js +16 -15
- package/lib/module/context/RookSyncGateProvider.js.map +1 -1
- package/lib/module/context/RookSyncGateReducer.js +2 -0
- package/lib/module/context/RookSyncGateReducer.js.map +1 -1
- package/lib/module/context/RookSyncGateTypes.js +2 -0
- package/lib/module/hooks/useRookAPISources.js +66 -0
- package/lib/module/hooks/useRookAPISources.js.map +1 -0
- package/lib/module/hooks/useRookAndroidBackgroundSteps.js +12 -25
- package/lib/module/hooks/useRookAndroidBackgroundSteps.js.map +1 -1
- package/lib/module/hooks/useRookAppleHealth.js +11 -23
- package/lib/module/hooks/useRookAppleHealth.js.map +1 -1
- package/lib/module/hooks/useRookConfiguration.js +10 -109
- package/lib/module/hooks/useRookConfiguration.js.map +1 -1
- package/lib/module/hooks/useRookData.js +35 -33
- package/lib/module/hooks/useRookData.js.map +1 -1
- package/lib/module/hooks/useRookHealthConnect.js +9 -10
- package/lib/module/hooks/useRookHealthConnect.js.map +1 -1
- package/lib/module/hooks/useRookPermissions.js +39 -77
- package/lib/module/hooks/useRookPermissions.js.map +1 -1
- package/lib/module/hooks/useRookSamsungHealth.js +35 -0
- package/lib/module/hooks/useRookSamsungHealth.js.map +1 -0
- package/lib/module/hooks/useRookSync.js +23 -31
- package/lib/module/hooks/useRookSync.js.map +1 -1
- package/lib/module/hooks/useRookVariables.js +24 -18
- package/lib/module/hooks/useRookVariables.js.map +1 -1
- package/lib/module/index.js +18 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/hook/useRookAutoSync.js +22 -36
- 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 +2 -0
- package/lib/module/modules/utils/errors.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/types/ActivityEvent.js +2 -0
- package/lib/module/types/AppleHealthPermissions.js +53 -0
- package/lib/module/types/AppleHealthPermissions.js.map +1 -0
- package/lib/module/types/AuthorizedSources.js +2 -0
- package/lib/module/types/BodySummary.js +2 -0
- package/lib/module/types/DataSource.js +10 -0
- package/lib/module/types/DataSource.js.map +1 -1
- package/lib/module/types/HeartRateEvent.js +2 -0
- package/lib/{commonjs/types/DataSource.js.map → module/types/HeartRateEvent.js.map} +1 -1
- package/lib/module/types/PermissionsType.js +1 -1
- package/lib/module/types/PhysicalSummary.js +2 -0
- package/lib/module/types/Rook.js +2 -0
- package/lib/{commonjs/types/SyncTypes.js.map → module/types/Rook.js.map} +1 -1
- package/lib/module/types/SDKSources.js +2 -0
- package/lib/module/types/SDKSources.js.map +1 -1
- package/lib/module/types/SamsungHealthPermissions.js +3 -0
- package/lib/module/types/SamsungHealthPermissions.js.map +1 -1
- package/lib/module/types/SleepSummary.js +2 -0
- package/lib/module/types/SummaryTypes.js +1 -1
- package/lib/module/types/SyncTypes.js +28 -1
- package/lib/module/types/SyncTypes.js.map +1 -1
- package/lib/module/utils/isModuleReady.js +2 -0
- package/lib/module/utils/isModuleReady.js.map +1 -1
- package/lib/module/utils/isRunningOnAndroid.js +2 -0
- package/lib/module/utils/isRunningOnAndroid.js.map +1 -1
- package/lib/module/utils/isRunningOniOS.js +2 -0
- package/lib/module/utils/isRunningOniOS.js.map +1 -1
- package/lib/module/utils/isValidDate.js +2 -0
- package/lib/module/utils/isValidDate.js.map +1 -1
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeRookSdk.d.ts +190 -0
- package/lib/typescript/src/NativeRookSdk.d.ts.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/hooks/useRookAPISources.d.ts +15 -0
- package/lib/typescript/src/hooks/useRookAPISources.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useRookAndroidBackgroundSteps.d.ts +0 -1
- package/lib/typescript/src/hooks/useRookAndroidBackgroundSteps.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookAppleHealth.d.ts +1 -2
- package/lib/typescript/src/hooks/useRookAppleHealth.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookConfiguration.d.ts +0 -8
- package/lib/typescript/src/hooks/useRookConfiguration.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookData.d.ts +2 -0
- 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 +11 -12
- package/lib/typescript/src/hooks/useRookPermissions.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookSamsungHealth.d.ts +7 -0
- package/lib/typescript/src/hooks/useRookSamsungHealth.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useRookSync.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookVariables.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +19 -4
- 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/AppleHealthPermissions.d.ts +50 -0
- package/lib/typescript/src/types/AppleHealthPermissions.d.ts.map +1 -0
- package/lib/typescript/src/types/AuthorizedSources.d.ts +3 -3
- package/lib/typescript/src/types/AuthorizedSources.d.ts.map +1 -1
- package/lib/typescript/src/types/DataSource.d.ts +8 -1
- package/lib/typescript/src/types/DataSource.d.ts.map +1 -1
- package/lib/typescript/src/types/HeartRateEvent.d.ts +24 -0
- package/lib/typescript/src/types/HeartRateEvent.d.ts.map +1 -0
- package/lib/typescript/src/types/PermissionsType.d.ts +0 -4
- package/lib/typescript/src/types/PermissionsType.d.ts.map +1 -1
- package/lib/typescript/src/types/Rook.d.ts +9 -0
- package/lib/typescript/src/types/Rook.d.ts.map +1 -0
- package/lib/typescript/src/types/SamsungHealthPermissions.d.ts +1 -0
- package/lib/typescript/src/types/SamsungHealthPermissions.d.ts.map +1 -1
- package/lib/typescript/src/types/SyncTypes.d.ts +28 -5
- package/lib/typescript/src/types/SyncTypes.d.ts.map +1 -1
- package/lib/typescript/src/utils/isModuleReady.d.ts.map +1 -1
- package/lib/typescript/src/utils/isValidDate.d.ts.map +1 -1
- package/package.json +94 -98
- package/src/NativeRookSdk.ts +282 -0
- package/{lib/commonjs/context/RookSyncGateContext.js → src/context/RookSyncGateContext.ts} +10 -13
- package/src/context/RookSyncGateProvider.tsx +78 -0
- package/{lib/commonjs/context/RookSyncGateReducer.js → src/context/RookSyncGateReducer.ts} +12 -33
- package/src/context/RookSyncGateTypes.ts +34 -0
- package/src/hooks/useRookAPISources.ts +83 -0
- package/src/hooks/useRookAndroidBackgroundSteps.ts +81 -0
- package/src/hooks/useRookAppleHealth.ts +55 -0
- package/src/hooks/useRookConfiguration.ts +82 -0
- package/src/hooks/useRookData.ts +122 -0
- package/src/hooks/useRookHealthConnect.ts +59 -0
- package/src/hooks/useRookPermissions.ts +224 -0
- package/src/hooks/useRookSamsungHealth.ts +37 -0
- package/src/hooks/useRookSync.ts +157 -0
- package/src/hooks/useRookVariables.ts +77 -0
- package/src/index.tsx +28 -0
- package/src/modules/hook/useRookAutoSync.ts +305 -0
- package/src/modules/types/sendMessageBroadcast.ts +5 -0
- package/src/modules/utils/errors.ts +9 -0
- package/src/types/ActivityEvent.ts +159 -0
- package/src/types/AppleHealthPermissions.ts +49 -0
- package/src/types/AuthorizedSources.ts +33 -0
- package/src/types/BodySummary.ts +116 -0
- package/src/types/DataSource.ts +16 -0
- package/src/types/HeartRateEvent.ts +26 -0
- package/src/types/PermissionsType.ts +9 -0
- package/src/types/PhysicalSummary.ts +84 -0
- package/src/types/Rook.ts +8 -0
- package/src/types/SDKSources.ts +5 -0
- package/src/types/SamsungHealthPermissions.ts +16 -0
- package/src/types/SleepSummary.ts +66 -0
- package/src/types/SummaryTypes.ts +70 -0
- package/src/types/SyncTypes.ts +63 -0
- package/{lib/commonjs/utils/isModuleReady.js → src/utils/isModuleReady.ts} +4 -10
- package/src/utils/isRunningOnAndroid.ts +10 -0
- package/src/utils/isRunningOniOS.ts +10 -0
- package/{lib/commonjs/utils/isValidDate.js → src/utils/isValidDate.ts} +5 -10
- package/android/src/main/AndroidManifestNew.xml +0 -36
- package/android/src/main/java/com/rooksdk/broadcasts/AndroidPermissionsReceiverTransmitter.kt +0 -65
- package/android/src/main/java/com/rooksdk/broadcasts/HealthConnectPermissionsReceiverTransmitter.kt +0 -70
- package/android/src/main/java/com/rooksdk/broadcasts/SamsungHealthPermissionsReceiverTransmitter.kt +0 -52
- package/android/src/main/java/com/rooksdk/modules/RookBackgroundSyncModule.kt +0 -85
- package/android/src/main/java/com/rooksdk/modules/RookConfigurationModule.kt +0 -148
- package/android/src/main/java/com/rooksdk/modules/RookLocalData.kt +0 -247
- package/android/src/main/java/com/rooksdk/modules/RookPermissionsModule.kt +0 -309
- package/android/src/main/java/com/rooksdk/modules/RookStepsModule.kt +0 -105
- package/android/src/main/java/com/rooksdk/modules/RookSyncModule.kt +0 -496
- package/android/src/main/java/com/rooksdk/utils/DatasourcesUtils.kt +0 -63
- package/android/src/main/java/com/rooksdk/utils/PermissionConversion.kt +0 -21
- package/android/src/main/java/com/rooksdk/utils/ReadableToWritable.kt +0 -64
- package/android/src/main/java/com/rooksdk/utils/RookDateTime.kt +0 -20
- package/android/src/main/java/com/rooksdk/utils/SamsungAvailability.kt +0 -21
- package/android/src/main/java/com/rooksdk/utils/Source.kt +0 -6
- package/android/src/main/java/com/rooksdk/utils/StringToSyncType.kt +0 -58
- package/android/src/main/java/com/rooksdk/utils/serializers/InstantSerializer.kt +0 -19
- package/android/src/main/java/com/rooksdk/utils/serializers/LocalDateSerializer.kt +0 -21
- package/android/src/main/res/drawable/ic_health_connect.xml +0 -19
- package/android/src/main/res/values/themes.xml +0 -3
- package/ios/EncodableRookDataSource.swift +0 -36
- package/ios/EncodableStatusDataSources.swift +0 -47
- package/ios/RookBackgroundModule.h +0 -5
- package/ios/RookBackgroundModule.mm +0 -89
- package/ios/RookConfigurationModule.h +0 -5
- package/ios/RookConfigurationModule.mm +0 -163
- package/ios/RookExternalModule.h +0 -5
- package/ios/RookExternalModule.m +0 -27
- package/ios/RookLocalData.swift +0 -152
- package/ios/RookPermissionsModule.h +0 -5
- package/ios/RookPermissionsModule.mm +0 -180
- package/ios/RookSourcesModule.h +0 -5
- package/ios/RookSourcesModule.mm +0 -67
- package/ios/RookSync.h +0 -5
- package/ios/RookSync.m +0 -27
- package/ios/RookSyncModule.h +0 -5
- package/ios/RookSyncModule.mm +0 -476
- package/ios/SwiftTest.swift +0 -18
- package/ios/react-native-rook-sdk-Bridging-Header.h +0 -12
- package/lib/commonjs/context/RookSyncGateContext.js.map +0 -1
- package/lib/commonjs/context/RookSyncGateProvider.js +0 -98
- package/lib/commonjs/context/RookSyncGateProvider.js.map +0 -1
- package/lib/commonjs/context/RookSyncGateReducer.js.map +0 -1
- package/lib/commonjs/context/RookSyncGateTypes.js +0 -6
- package/lib/commonjs/context/RookSyncGateTypes.js.map +0 -1
- package/lib/commonjs/context/index.js +0 -14
- package/lib/commonjs/context/index.js.map +0 -1
- package/lib/commonjs/hooks/index.js +0 -90
- package/lib/commonjs/hooks/index.js.map +0 -1
- package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js +0 -100
- package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js.map +0 -1
- package/lib/commonjs/hooks/useRookAppleHealth.js +0 -74
- package/lib/commonjs/hooks/useRookAppleHealth.js.map +0 -1
- package/lib/commonjs/hooks/useRookAppleHealthVariables.js +0 -48
- package/lib/commonjs/hooks/useRookAppleHealthVariables.js.map +0 -1
- package/lib/commonjs/hooks/useRookConfiguration.js +0 -188
- package/lib/commonjs/hooks/useRookConfiguration.js.map +0 -1
- package/lib/commonjs/hooks/useRookData.js +0 -100
- package/lib/commonjs/hooks/useRookData.js.map +0 -1
- package/lib/commonjs/hooks/useRookDataSources.js +0 -118
- package/lib/commonjs/hooks/useRookDataSources.js.map +0 -1
- package/lib/commonjs/hooks/useRookEvents.js +0 -225
- package/lib/commonjs/hooks/useRookEvents.js.map +0 -1
- package/lib/commonjs/hooks/useRookHealthConnect.js +0 -70
- package/lib/commonjs/hooks/useRookHealthConnect.js.map +0 -1
- package/lib/commonjs/hooks/useRookPermissions.js +0 -226
- package/lib/commonjs/hooks/useRookPermissions.js.map +0 -1
- package/lib/commonjs/hooks/useRookSummaries.js +0 -85
- package/lib/commonjs/hooks/useRookSummaries.js.map +0 -1
- package/lib/commonjs/hooks/useRookSync.js +0 -147
- package/lib/commonjs/hooks/useRookSync.js.map +0 -1
- package/lib/commonjs/hooks/useRookVariables.js +0 -69
- package/lib/commonjs/hooks/useRookVariables.js.map +0 -1
- package/lib/commonjs/index.js +0 -56
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/modules/hook/useRookAutoSync.js +0 -262
- package/lib/commonjs/modules/hook/useRookAutoSync.js.map +0 -1
- package/lib/commonjs/modules/types/sendMessageBroadcast.js +0 -2
- package/lib/commonjs/modules/types/sendMessageBroadcast.js.map +0 -1
- package/lib/commonjs/modules/utils/errors.js +0 -12
- package/lib/commonjs/modules/utils/errors.js.map +0 -1
- package/lib/commonjs/types/ActivityEvent.js +0 -6
- package/lib/commonjs/types/ActivityEvent.js.map +0 -1
- package/lib/commonjs/types/AuthorizedSources.js +0 -2
- package/lib/commonjs/types/AuthorizedSources.js.map +0 -1
- package/lib/commonjs/types/BodySummary.js +0 -6
- package/lib/commonjs/types/BodySummary.js.map +0 -1
- package/lib/commonjs/types/DataSource.js +0 -2
- package/lib/commonjs/types/PermissionsType.js +0 -2
- package/lib/commonjs/types/PermissionsType.js.map +0 -1
- package/lib/commonjs/types/PhysicalSummary.js +0 -6
- package/lib/commonjs/types/PhysicalSummary.js.map +0 -1
- package/lib/commonjs/types/SDKSources.js +0 -13
- package/lib/commonjs/types/SDKSources.js.map +0 -1
- package/lib/commonjs/types/SamsungHealthPermissions.js +0 -23
- package/lib/commonjs/types/SamsungHealthPermissions.js.map +0 -1
- package/lib/commonjs/types/SleepSummary.js +0 -6
- package/lib/commonjs/types/SleepSummary.js.map +0 -1
- package/lib/commonjs/types/SummaryTypes.js +0 -2
- package/lib/commonjs/types/SummaryTypes.js.map +0 -1
- package/lib/commonjs/types/SyncTypes.js +0 -6
- package/lib/commonjs/utils/credentials.js +0 -12
- package/lib/commonjs/utils/credentials.js.map +0 -1
- package/lib/commonjs/utils/getNativeModule.js +0 -29
- package/lib/commonjs/utils/getNativeModule.js.map +0 -1
- package/lib/commonjs/utils/getRookModule.js +0 -28
- package/lib/commonjs/utils/getRookModule.js.map +0 -1
- package/lib/commonjs/utils/isModuleReady.js.map +0 -1
- package/lib/commonjs/utils/isRunningOnAndroid.js +0 -15
- package/lib/commonjs/utils/isRunningOnAndroid.js.map +0 -1
- package/lib/commonjs/utils/isRunningOniOS.js +0 -15
- package/lib/commonjs/utils/isRunningOniOS.js.map +0 -1
- package/lib/commonjs/utils/isValidDate.js.map +0 -1
- package/lib/commonjs/utils/nativeModules.js +0 -28
- package/lib/commonjs/utils/nativeModules.js.map +0 -1
- package/lib/commonjs/utils/packageInfo.js +0 -13
- package/lib/commonjs/utils/packageInfo.js.map +0 -1
- package/lib/module/context/index.js +0 -2
- package/lib/module/context/index.js.map +0 -1
- package/lib/module/hooks/index.js +0 -13
- package/lib/module/hooks/index.js.map +0 -1
- package/lib/module/hooks/useRookAppleHealthVariables.js +0 -41
- package/lib/module/hooks/useRookAppleHealthVariables.js.map +0 -1
- package/lib/module/hooks/useRookDataSources.js +0 -110
- package/lib/module/hooks/useRookDataSources.js.map +0 -1
- package/lib/module/hooks/useRookEvents.js +0 -218
- package/lib/module/hooks/useRookEvents.js.map +0 -1
- package/lib/module/hooks/useRookSummaries.js +0 -78
- package/lib/module/hooks/useRookSummaries.js.map +0 -1
- package/lib/module/utils/credentials.js +0 -6
- package/lib/module/utils/credentials.js.map +0 -1
- package/lib/module/utils/getNativeModule.js +0 -23
- package/lib/module/utils/getNativeModule.js.map +0 -1
- package/lib/module/utils/getRookModule.js +0 -22
- package/lib/module/utils/getRookModule.js.map +0 -1
- package/lib/module/utils/nativeModules.js +0 -22
- package/lib/module/utils/nativeModules.js.map +0 -1
- package/lib/module/utils/packageInfo.js +0 -7
- package/lib/module/utils/packageInfo.js.map +0 -1
- package/lib/typescript/src/context/index.d.ts +0 -2
- package/lib/typescript/src/context/index.d.ts.map +0 -1
- package/lib/typescript/src/hooks/index.d.ts +0 -13
- package/lib/typescript/src/hooks/index.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useRookAppleHealthVariables.d.ts +0 -15
- package/lib/typescript/src/hooks/useRookAppleHealthVariables.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useRookDataSources.d.ts +0 -22
- package/lib/typescript/src/hooks/useRookDataSources.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useRookEvents.d.ts +0 -26
- package/lib/typescript/src/hooks/useRookEvents.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useRookSummaries.d.ts +0 -14
- package/lib/typescript/src/hooks/useRookSummaries.d.ts.map +0 -1
- package/lib/typescript/src/utils/credentials.d.ts +0 -5
- package/lib/typescript/src/utils/credentials.d.ts.map +0 -1
- package/lib/typescript/src/utils/getNativeModule.d.ts +0 -10
- package/lib/typescript/src/utils/getNativeModule.d.ts.map +0 -1
- package/lib/typescript/src/utils/getRookModule.d.ts +0 -9
- package/lib/typescript/src/utils/getRookModule.d.ts.map +0 -1
- package/lib/typescript/src/utils/nativeModules.d.ts +0 -23
- package/lib/typescript/src/utils/nativeModules.d.ts.map +0 -1
- package/lib/typescript/src/utils/packageInfo.d.ts +0 -6
- package/lib/typescript/src/utils/packageInfo.d.ts.map +0 -1
- package/react-native-rook-sdk.podspec +0 -45
package/ios/RookSdk.mm
CHANGED
|
@@ -1,40 +1,399 @@
|
|
|
1
1
|
#import "RookSdk.h"
|
|
2
|
-
#import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
#import "RNRookSdk-Swift.h"
|
|
3
|
+
|
|
4
|
+
@implementation RNRookSdk {
|
|
5
|
+
BOOL shouldEmitEvent;
|
|
6
|
+
RookEntry *entry;
|
|
7
|
+
RookSources *sources;
|
|
8
|
+
RookConfiguration *config;
|
|
9
|
+
RookBackground *bg;
|
|
10
|
+
RookPermissions *perm;
|
|
11
|
+
RookData *data;
|
|
12
|
+
RookSync *sync;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
}
|
|
24
29
|
|
|
25
|
-
|
|
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);
|
|
26
36
|
}
|
|
27
37
|
|
|
28
|
-
|
|
29
|
-
@implementation RookSdk
|
|
38
|
+
+ (NSString *)moduleName
|
|
30
39
|
{
|
|
31
|
-
|
|
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
|
+
}];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
-(void)invalidate {
|
|
66
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
67
|
+
shouldEmitEvent = NO;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
- (void)isNotiOSSupported:(nonnull RCTPromiseRejectBlock)reject{
|
|
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];
|
|
32
110
|
}
|
|
33
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];
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
- (void)syncEvent:(nonnull NSString *)date event:(nonnull NSString *)event resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
373
|
+
[sync syncEvent:date event:event resolve:resolve reject:reject];
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
- (void)sendMessage:(JS::NativeRookSdk::Message &)message resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
377
|
+
|
|
378
|
+
if (shouldEmitEvent) {
|
|
379
|
+
NSMutableDictionary *messageInfo = [[NSMutableDictionary alloc] init];
|
|
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
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
#else
|
|
392
|
+
// --- BRIDGE (Old Arch) ---
|
|
34
393
|
RCT_EXPORT_MODULE()
|
|
35
394
|
|
|
36
395
|
-(void)startObserving {
|
|
37
|
-
|
|
396
|
+
shouldEmitEvent = YES;
|
|
38
397
|
|
|
39
398
|
NSLog(@"Hay alguien escuchando");
|
|
40
399
|
|
|
@@ -46,7 +405,7 @@ RCT_EXPORT_MODULE()
|
|
|
46
405
|
|
|
47
406
|
// Will be called when this module's last listener is removed, or on dealloc.
|
|
48
407
|
-(void)stopObserving {
|
|
49
|
-
|
|
408
|
+
shouldEmitEvent = NO;
|
|
50
409
|
|
|
51
410
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
52
411
|
}
|
|
@@ -70,79 +429,188 @@ RCT_EXPORT_MODULE()
|
|
|
70
429
|
message[@"message"] = notificationInfo[@"Error"].localizedDescription;
|
|
71
430
|
message[@"code"] = notificationInfo[@"Error"].description;
|
|
72
431
|
|
|
73
|
-
if (
|
|
432
|
+
if (shouldEmitEvent)
|
|
74
433
|
[self sendEventWithName:@"ROOK_NOTIFICATION" body: message];
|
|
75
434
|
}
|
|
76
435
|
}
|
|
77
436
|
|
|
78
|
-
RookConnectConfigurationManagerObjc *shared;
|
|
79
|
-
|
|
80
|
-
// MARK: - Configuration
|
|
81
|
-
/**
|
|
82
|
-
* Initializes the Rook SDK with the provided configuration.
|
|
83
|
-
*
|
|
84
|
-
* @param data A dictionary containing the configuration parameters:
|
|
85
|
-
* - clientUUID: The unique identifier for the client.
|
|
86
|
-
* - password: The client's secret key.
|
|
87
|
-
* - enableEventsBackgroundSync: A boolean indicating whether to enable background sync for events.
|
|
88
|
-
* - environment: The environment in which the SDK is running (production, sandbox, or development).
|
|
89
|
-
* - enableLogs: A boolean indicating whether console logs should be enabled.
|
|
90
|
-
* @param resolve A block called upon successful initialization.
|
|
91
|
-
* @param reject A block called if an error occurs during initialization.
|
|
92
|
-
*/
|
|
93
437
|
RCT_EXPORT_METHOD(initRook:(NSDictionary *) data
|
|
94
438
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
95
439
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
NSString *environment = convertToString(data[@"environment"]);
|
|
104
|
-
BOOL enableLogs = [RCTConvert BOOL:data[@"enableLogs"]];
|
|
105
|
-
|
|
106
|
-
NSDictionary *opcionActions = @{
|
|
107
|
-
@"production": ^{
|
|
108
|
-
[shared setEnvironmentForProduction];
|
|
109
|
-
[[IOSClass shared] disableTest];
|
|
110
|
-
},
|
|
111
|
-
@"sandbox": ^{
|
|
112
|
-
[shared setEnvironmentForSandbox];
|
|
113
|
-
[[IOSClass shared] disableTest];
|
|
114
|
-
},
|
|
115
|
-
@"development": ^{
|
|
116
|
-
[[IOSClass shared] test];
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
void (^selectAction)(void) = opcionActions[environment];
|
|
121
|
-
if (selectAction) selectAction();
|
|
122
|
-
|
|
123
|
-
[shared setConsoleLogAvailable: enableLogs];
|
|
124
|
-
[shared initRook];
|
|
125
|
-
|
|
126
|
-
resolve(@(YES));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
440
|
+
|
|
441
|
+
NSMutableDictionary *dict = [NSMutableDictionary new];
|
|
442
|
+
dict[@"password"] = options.password();
|
|
443
|
+
dict[@"environment"] = options.environment();
|
|
444
|
+
dict[@"clientUUID"] = options.clientUUID();
|
|
445
|
+
dict[@"enableBackground"] = @(options.enableBackground());
|
|
446
|
+
dict[@"enableEventsBackgroundSync"] = @(options.enableEventsBackgroundSync());
|
|
130
447
|
|
|
131
|
-
|
|
448
|
+
[entry initRook:dict resolve:resolve reject:reject];
|
|
449
|
+
}
|
|
132
450
|
|
|
133
451
|
/**
|
|
134
|
-
* Internal method to send messages to broadcast channel
|
|
452
|
+
* Internal method to send messages to broadcast channel
|
|
135
453
|
*
|
|
136
454
|
* @param resolve A block called with a boolean value indicating whether the result is.
|
|
137
455
|
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
138
456
|
*/
|
|
139
|
-
RCT_EXPORT_METHOD(
|
|
457
|
+
RCT_EXPORT_METHOD(sendMessage: (NSDictionary *) message
|
|
140
458
|
resolve: (RCTPromiseResolveBlock) resolve
|
|
141
459
|
reject: (RCTPromiseRejectBlock) reject) {
|
|
142
|
-
if(
|
|
460
|
+
if(shouldEmitEvent) {
|
|
143
461
|
[self sendEventWithName:@"ROOK_NOTIFICATION" body:message];
|
|
144
462
|
}
|
|
145
463
|
}
|
|
146
|
-
@end
|
|
147
464
|
|
|
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
|
+
}
|
|
148
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
|
+
|
|
616
|
+
@end
|