react-native-rook-sdk 4.0.0 → 5.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +35 -3
  3. package/RNRookSdk.podspec +22 -0
  4. package/android/build.gradle +21 -40
  5. package/android/gradle.properties +5 -5
  6. package/android/src/main/AndroidManifest.xml +1 -2
  7. package/android/src/main/java/com/rooksdk/RookSdkModule.kt +1709 -117
  8. package/android/src/main/java/com/rooksdk/RookSdkPackage.kt +26 -42
  9. package/android/src/main/java/com/rooksdk/broadcasts/AndroidPermissionsReceiverTransmitter.kt +34 -37
  10. package/android/src/main/java/com/rooksdk/broadcasts/HealthConnectPermissionsReceiverTransmitter.kt +8 -14
  11. package/android/src/main/java/com/rooksdk/broadcasts/SamsungHealthPermissionsReceiverTransmitter.kt +8 -16
  12. package/android/src/main/java/com/rooksdk/utils/{DatasourcesUtils.kt → DatasourceUtils.kt} +10 -9
  13. package/android/src/main/java/com/rooksdk/utils/{PermissionConversion.kt → PermissionConvertions.kt} +1 -1
  14. package/android/src/main/java/com/rooksdk/utils/ReadableToWritable.kt +0 -1
  15. package/android/src/main/java/com/rooksdk/utils/RookGsonBuilder.kt +3 -0
  16. package/android/src/main/java/com/rooksdk/utils/SamsungAvailability.kt +1 -0
  17. package/android/src/main/java/com/rooksdk/utils/serializers/InstantSerializer.kt +0 -1
  18. package/android/src/main/java/com/rooksdk/utils/serializers/ZoneDateTimeSerializer.kt +18 -0
  19. package/ios/DateHelper.swift +4 -4
  20. package/ios/Encodable.swift +25 -0
  21. package/ios/EncodableDataSource.swift +2 -3
  22. package/ios/EncodableDataSourceAuthorizer.swift +2 -3
  23. package/ios/EncodableSDKState.swift +3 -2
  24. package/ios/{EncodableHeartRate.swift → HearRateMapper.swift} +3 -3
  25. package/ios/NutritionMapper.swift +3 -3
  26. package/ios/RookBackground.swift +5 -8
  27. package/ios/RookConfiguration.swift +33 -30
  28. package/ios/{RookLocalData.swift → RookData.swift} +76 -69
  29. package/ios/RookEntry.swift +62 -0
  30. package/ios/RookPermissions.swift +36 -40
  31. package/ios/RookSdk-Bridging-Header.h +12 -0
  32. package/ios/RookSdk.h +3 -3
  33. package/ios/RookSdk.mm +390 -134
  34. package/ios/RookSources.swift +60 -54
  35. package/ios/RookSync.swift +48 -78
  36. package/ios/boost-boost_privacy-Bridging-Header.h +4 -0
  37. package/lib/{commonjs/types/AppleHealthPermissions.js → module/NativeRookSdk.js} +50 -6
  38. package/lib/module/NativeRookSdk.js.map +1 -0
  39. package/lib/module/context/RookSyncGateContext.js +2 -0
  40. package/lib/module/context/RookSyncGateContext.js.map +1 -1
  41. package/lib/module/context/RookSyncGateProvider.js +17 -18
  42. package/lib/module/context/RookSyncGateProvider.js.map +1 -1
  43. package/lib/module/context/RookSyncGateReducer.js +2 -0
  44. package/lib/module/context/RookSyncGateReducer.js.map +1 -1
  45. package/lib/module/context/RookSyncGateTypes.js +2 -0
  46. package/lib/module/hooks/useRookAPISources.js +10 -16
  47. package/lib/module/hooks/useRookAPISources.js.map +1 -1
  48. package/lib/module/hooks/useRookAndroidBackgroundSteps.js +11 -12
  49. package/lib/module/hooks/useRookAndroidBackgroundSteps.js.map +1 -1
  50. package/lib/module/hooks/useRookAppleHealth.js +9 -10
  51. package/lib/module/hooks/useRookAppleHealth.js.map +1 -1
  52. package/lib/module/hooks/useRookConfiguration.js +17 -22
  53. package/lib/module/hooks/useRookConfiguration.js.map +1 -1
  54. package/lib/module/hooks/useRookData.js +33 -38
  55. package/lib/module/hooks/useRookData.js.map +1 -1
  56. package/lib/module/hooks/useRookHealthConnect.js +9 -10
  57. package/lib/module/hooks/useRookHealthConnect.js.map +1 -1
  58. package/lib/module/hooks/useRookPermissions.js +34 -45
  59. package/lib/module/hooks/useRookPermissions.js.map +1 -1
  60. package/lib/module/hooks/useRookSamsungHealth.js +8 -20
  61. package/lib/module/hooks/useRookSamsungHealth.js.map +1 -1
  62. package/lib/module/hooks/useRookSync.js +23 -32
  63. package/lib/module/hooks/useRookSync.js.map +1 -1
  64. package/lib/module/hooks/useRookVariables.js +26 -29
  65. package/lib/module/hooks/useRookVariables.js.map +1 -1
  66. package/lib/module/index.js +18 -10
  67. package/lib/module/index.js.map +1 -1
  68. package/lib/module/modules/components/RookStateManager.js +31 -0
  69. package/lib/module/modules/components/RookStateManager.js.map +1 -0
  70. package/lib/module/modules/hook/useRookAutoSync.js +24 -36
  71. package/lib/module/modules/hook/useRookAutoSync.js.map +1 -1
  72. package/lib/module/modules/hook/useRookEmitter.js +61 -0
  73. package/lib/module/modules/hook/useRookEmitter.js.map +1 -0
  74. package/lib/module/modules/types/sendMessageBroadcast.js +1 -1
  75. package/lib/module/modules/utils/errors.js +2 -0
  76. package/lib/module/modules/utils/errors.js.map +1 -1
  77. package/lib/module/package.json +1 -0
  78. package/lib/module/types/ActivityEvent.js +2 -0
  79. package/lib/module/types/AppleHealthNutritionEvent.js +2 -0
  80. package/lib/module/types/AppleHealthNutritionEvent.js.map +1 -1
  81. package/lib/module/types/AppleHealthPermissions.js +2 -0
  82. package/lib/module/types/AppleHealthPermissions.js.map +1 -1
  83. package/lib/module/types/AuthorizedSources.js +2 -0
  84. package/lib/module/types/BodySummary.js +2 -0
  85. package/lib/module/types/DataSource.js +2 -0
  86. package/lib/module/types/DataSource.js.map +1 -1
  87. package/lib/module/types/HCMealData.js +3 -1
  88. package/lib/module/types/HCMealData.js.map +1 -1
  89. package/lib/module/types/HeartRateEvent.js +1 -1
  90. package/lib/module/types/PermissionsType.js +1 -1
  91. package/lib/module/types/PhysicalSummary.js +2 -0
  92. package/lib/module/types/Rook.js +2 -0
  93. package/lib/{commonjs/types/BodySummary.js.map → module/types/Rook.js.map} +1 -1
  94. package/lib/module/types/SDKSources.js +2 -0
  95. package/lib/module/types/SDKSources.js.map +1 -1
  96. package/lib/module/types/SamsungHealthPermissions.js +3 -0
  97. package/lib/module/types/SamsungHealthPermissions.js.map +1 -1
  98. package/lib/module/types/SleepSummary.js +2 -0
  99. package/lib/module/types/SummaryTypes.js +1 -1
  100. package/lib/module/types/SyncTypes.js +2 -0
  101. package/lib/module/types/SyncTypes.js.map +1 -1
  102. package/lib/module/types/WriteNutrition.js +2 -0
  103. package/lib/module/types/WriteNutrition.js.map +1 -1
  104. package/lib/module/utils/isModuleReady.js +2 -0
  105. package/lib/module/utils/isModuleReady.js.map +1 -1
  106. package/lib/module/utils/isRunningOnAndroid.js +2 -0
  107. package/lib/module/utils/isRunningOnAndroid.js.map +1 -1
  108. package/lib/module/utils/isRunningOniOS.js +2 -0
  109. package/lib/module/utils/isRunningOniOS.js.map +1 -1
  110. package/lib/module/utils/isValidDate.js +2 -0
  111. package/lib/module/utils/isValidDate.js.map +1 -1
  112. package/lib/typescript/package.json +1 -0
  113. package/lib/typescript/src/NativeRookSdk.d.ts +705 -0
  114. package/lib/typescript/src/NativeRookSdk.d.ts.map +1 -0
  115. package/lib/typescript/src/context/RookSyncGateContext.d.ts.map +1 -1
  116. package/lib/typescript/src/context/RookSyncGateProvider.d.ts.map +1 -1
  117. package/lib/typescript/src/context/RookSyncGateReducer.d.ts.map +1 -1
  118. package/lib/typescript/src/hooks/useRookAPISources.d.ts.map +1 -1
  119. package/lib/typescript/src/hooks/useRookAndroidBackgroundSteps.d.ts.map +1 -1
  120. package/lib/typescript/src/hooks/useRookAppleHealth.d.ts.map +1 -1
  121. package/lib/typescript/src/hooks/useRookConfiguration.d.ts +1 -1
  122. package/lib/typescript/src/hooks/useRookConfiguration.d.ts.map +1 -1
  123. package/lib/typescript/src/hooks/useRookData.d.ts +1 -1
  124. package/lib/typescript/src/hooks/useRookData.d.ts.map +1 -1
  125. package/lib/typescript/src/hooks/useRookHealthConnect.d.ts.map +1 -1
  126. package/lib/typescript/src/hooks/useRookPermissions.d.ts +1 -1
  127. package/lib/typescript/src/hooks/useRookPermissions.d.ts.map +1 -1
  128. package/lib/typescript/src/hooks/useRookSamsungHealth.d.ts +0 -6
  129. package/lib/typescript/src/hooks/useRookSamsungHealth.d.ts.map +1 -1
  130. package/lib/typescript/src/hooks/useRookSync.d.ts.map +1 -1
  131. package/lib/typescript/src/hooks/useRookVariables.d.ts +1 -1
  132. package/lib/typescript/src/hooks/useRookVariables.d.ts.map +1 -1
  133. package/lib/typescript/src/index.d.ts +18 -8
  134. package/lib/typescript/src/index.d.ts.map +1 -1
  135. package/lib/typescript/src/modules/components/RookStateManager.d.ts +10 -0
  136. package/lib/typescript/src/modules/components/RookStateManager.d.ts.map +1 -0
  137. package/lib/typescript/src/modules/hook/useRookAutoSync.d.ts.map +1 -1
  138. package/lib/typescript/src/modules/hook/useRookEmitter.d.ts +4 -0
  139. package/lib/typescript/src/modules/hook/useRookEmitter.d.ts.map +1 -0
  140. package/lib/typescript/src/types/AppleHealthNutritionEvent.d.ts.map +1 -1
  141. package/lib/typescript/src/types/AuthorizedSources.d.ts +11 -0
  142. package/lib/typescript/src/types/AuthorizedSources.d.ts.map +1 -1
  143. package/lib/typescript/src/types/HCMealData.d.ts.map +1 -1
  144. package/lib/typescript/src/types/HeartRateEvent.d.ts +2 -2
  145. package/lib/typescript/src/types/HeartRateEvent.d.ts.map +1 -1
  146. package/lib/typescript/src/types/Rook.d.ts +9 -0
  147. package/lib/typescript/src/types/Rook.d.ts.map +1 -0
  148. package/lib/typescript/src/types/SamsungHealthPermissions.d.ts +1 -0
  149. package/lib/typescript/src/types/SamsungHealthPermissions.d.ts.map +1 -1
  150. package/lib/typescript/src/types/SyncTypes.d.ts +5 -1
  151. package/lib/typescript/src/types/SyncTypes.d.ts.map +1 -1
  152. package/lib/typescript/src/utils/isModuleReady.d.ts.map +1 -1
  153. package/lib/typescript/src/utils/isValidDate.d.ts.map +1 -1
  154. package/package.json +94 -98
  155. package/src/NativeRookSdk.ts +839 -0
  156. package/{lib/commonjs/context/RookSyncGateContext.js → src/context/RookSyncGateContext.ts} +10 -13
  157. package/src/context/RookSyncGateProvider.tsx +82 -0
  158. package/{lib/commonjs/context/RookSyncGateReducer.js → src/context/RookSyncGateReducer.ts} +14 -41
  159. package/src/context/RookSyncGateTypes.ts +40 -0
  160. package/{lib/commonjs/hooks/useRookAPISources.js → src/hooks/useRookAPISources.ts} +40 -36
  161. package/src/hooks/useRookAndroidBackgroundSteps.ts +81 -0
  162. package/src/hooks/useRookAppleHealth.ts +55 -0
  163. package/src/hooks/useRookConfiguration.ts +106 -0
  164. package/src/hooks/useRookData.ts +133 -0
  165. package/src/hooks/useRookHealthConnect.ts +59 -0
  166. package/src/hooks/useRookPermissions.ts +240 -0
  167. package/src/hooks/useRookSamsungHealth.ts +37 -0
  168. package/src/hooks/useRookSync.ts +157 -0
  169. package/src/hooks/useRookVariables.ts +98 -0
  170. package/src/index.tsx +29 -0
  171. package/src/modules/components/RookStateManager.tsx +41 -0
  172. package/{lib/commonjs/modules/hook/useRookAutoSync.js → src/modules/hook/useRookAutoSync.ts} +141 -95
  173. package/src/modules/hook/useRookEmitter.ts +94 -0
  174. package/src/modules/types/sendMessageBroadcast.ts +5 -0
  175. package/src/modules/utils/errors.ts +9 -0
  176. package/src/types/ActivityEvent.ts +159 -0
  177. package/src/types/AppleHealthNutritionEvent.ts +142 -0
  178. package/src/types/AppleHealthPermissions.ts +49 -0
  179. package/src/types/AuthorizedSources.ts +33 -0
  180. package/src/types/BodySummary.ts +116 -0
  181. package/src/types/DataSource.ts +16 -0
  182. package/{lib/commonjs/types/HCMealData.js → src/types/HCMealData.ts} +60 -11
  183. package/src/types/HeartRateEvent.ts +26 -0
  184. package/src/types/PermissionsType.ts +9 -0
  185. package/src/types/PhysicalSummary.ts +84 -0
  186. package/src/types/Rook.ts +8 -0
  187. package/src/types/SDKSources.ts +5 -0
  188. package/src/types/SamsungHealthPermissions.ts +16 -0
  189. package/src/types/SleepSummary.ts +66 -0
  190. package/src/types/SummaryTypes.ts +70 -0
  191. package/src/types/SyncTypes.ts +63 -0
  192. package/src/types/WriteNutrition.ts +66 -0
  193. package/{lib/commonjs/utils/isModuleReady.js → src/utils/isModuleReady.ts} +4 -10
  194. package/src/utils/isRunningOnAndroid.ts +10 -0
  195. package/src/utils/isRunningOniOS.ts +10 -0
  196. package/{lib/commonjs/utils/isValidDate.js → src/utils/isValidDate.ts} +12 -14
  197. package/android/src/main/AndroidManifestNew.xml +0 -36
  198. package/android/src/main/java/com/rooksdk/modules/RookBackgroundSyncModule.kt +0 -99
  199. package/android/src/main/java/com/rooksdk/modules/RookConfigurationModule.kt +0 -182
  200. package/android/src/main/java/com/rooksdk/modules/RookLocalData.kt +0 -301
  201. package/android/src/main/java/com/rooksdk/modules/RookPermissionsModule.kt +0 -359
  202. package/android/src/main/java/com/rooksdk/modules/RookSourcesModule.kt +0 -102
  203. package/android/src/main/java/com/rooksdk/modules/RookStepsModule.kt +0 -119
  204. package/android/src/main/java/com/rooksdk/modules/RookSyncModule.kt +0 -551
  205. package/android/src/main/res/drawable/ic_health_connect.xml +0 -19
  206. package/android/src/main/res/values/themes.xml +0 -3
  207. package/ios/EncodableRookDataSource.swift +0 -36
  208. package/ios/EncodableStatusDataSources.swift +0 -47
  209. package/ios/RookBackgroundModule.h +0 -5
  210. package/ios/RookBackgroundModule.mm +0 -15
  211. package/ios/RookConfigurationModule.h +0 -5
  212. package/ios/RookConfigurationModule.mm +0 -22
  213. package/ios/RookExternalModule.h +0 -5
  214. package/ios/RookExternalModule.m +0 -31
  215. package/ios/RookPermissionsModule.h +0 -5
  216. package/ios/RookPermissionsModule.mm +0 -20
  217. package/ios/RookSourcesModule.h +0 -5
  218. package/ios/RookSourcesModule.mm +0 -18
  219. package/ios/RookSync.h +0 -5
  220. package/ios/RookSync.m +0 -35
  221. package/ios/SwiftTest.swift +0 -18
  222. package/ios/react-native-rook-sdk-Bridging-Header.h +0 -12
  223. package/lib/commonjs/context/RookSyncGateContext.js.map +0 -1
  224. package/lib/commonjs/context/RookSyncGateProvider.js +0 -108
  225. package/lib/commonjs/context/RookSyncGateProvider.js.map +0 -1
  226. package/lib/commonjs/context/RookSyncGateReducer.js.map +0 -1
  227. package/lib/commonjs/context/RookSyncGateTypes.js +0 -6
  228. package/lib/commonjs/context/RookSyncGateTypes.js.map +0 -1
  229. package/lib/commonjs/context/index.js +0 -14
  230. package/lib/commonjs/context/index.js.map +0 -1
  231. package/lib/commonjs/hooks/index.js +0 -76
  232. package/lib/commonjs/hooks/index.js.map +0 -1
  233. package/lib/commonjs/hooks/useRookAPISources.js.map +0 -1
  234. package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js +0 -88
  235. package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js.map +0 -1
  236. package/lib/commonjs/hooks/useRookAppleHealth.js +0 -63
  237. package/lib/commonjs/hooks/useRookAppleHealth.js.map +0 -1
  238. package/lib/commonjs/hooks/useRookConfiguration.js +0 -113
  239. package/lib/commonjs/hooks/useRookConfiguration.js.map +0 -1
  240. package/lib/commonjs/hooks/useRookData.js +0 -116
  241. package/lib/commonjs/hooks/useRookData.js.map +0 -1
  242. package/lib/commonjs/hooks/useRookHealthConnect.js +0 -70
  243. package/lib/commonjs/hooks/useRookHealthConnect.js.map +0 -1
  244. package/lib/commonjs/hooks/useRookPermissions.js +0 -211
  245. package/lib/commonjs/hooks/useRookPermissions.js.map +0 -1
  246. package/lib/commonjs/hooks/useRookSamsungHealth.js +0 -54
  247. package/lib/commonjs/hooks/useRookSamsungHealth.js.map +0 -1
  248. package/lib/commonjs/hooks/useRookSync.js +0 -148
  249. package/lib/commonjs/hooks/useRookSync.js.map +0 -1
  250. package/lib/commonjs/hooks/useRookVariables.js +0 -93
  251. package/lib/commonjs/hooks/useRookVariables.js.map +0 -1
  252. package/lib/commonjs/index.js +0 -121
  253. package/lib/commonjs/index.js.map +0 -1
  254. package/lib/commonjs/modules/hook/useRookAutoSync.js.map +0 -1
  255. package/lib/commonjs/modules/types/sendMessageBroadcast.js +0 -2
  256. package/lib/commonjs/modules/types/sendMessageBroadcast.js.map +0 -1
  257. package/lib/commonjs/modules/utils/errors.js +0 -12
  258. package/lib/commonjs/modules/utils/errors.js.map +0 -1
  259. package/lib/commonjs/types/ActivityEvent.js +0 -6
  260. package/lib/commonjs/types/ActivityEvent.js.map +0 -1
  261. package/lib/commonjs/types/AppleHealthNutritionEvent.js +0 -77
  262. package/lib/commonjs/types/AppleHealthNutritionEvent.js.map +0 -1
  263. package/lib/commonjs/types/AppleHealthPermissions.js.map +0 -1
  264. package/lib/commonjs/types/AuthorizedSources.js +0 -6
  265. package/lib/commonjs/types/AuthorizedSources.js.map +0 -1
  266. package/lib/commonjs/types/BodySummary.js +0 -6
  267. package/lib/commonjs/types/DataSource.js +0 -16
  268. package/lib/commonjs/types/DataSource.js.map +0 -1
  269. package/lib/commonjs/types/DiagnosticState.js +0 -2
  270. package/lib/commonjs/types/DiagnosticState.js.map +0 -1
  271. package/lib/commonjs/types/HCMealData.js.map +0 -1
  272. package/lib/commonjs/types/HeartRateEvent.js +0 -2
  273. package/lib/commonjs/types/HeartRateEvent.js.map +0 -1
  274. package/lib/commonjs/types/PermissionsType.js +0 -2
  275. package/lib/commonjs/types/PermissionsType.js.map +0 -1
  276. package/lib/commonjs/types/PhysicalSummary.js +0 -6
  277. package/lib/commonjs/types/PhysicalSummary.js.map +0 -1
  278. package/lib/commonjs/types/SDKSources.js +0 -13
  279. package/lib/commonjs/types/SDKSources.js.map +0 -1
  280. package/lib/commonjs/types/SamsungHealthPermissions.js +0 -23
  281. package/lib/commonjs/types/SamsungHealthPermissions.js.map +0 -1
  282. package/lib/commonjs/types/SleepSummary.js +0 -6
  283. package/lib/commonjs/types/SleepSummary.js.map +0 -1
  284. package/lib/commonjs/types/SummaryTypes.js +0 -2
  285. package/lib/commonjs/types/SummaryTypes.js.map +0 -1
  286. package/lib/commonjs/types/SyncTypes.js +0 -33
  287. package/lib/commonjs/types/SyncTypes.js.map +0 -1
  288. package/lib/commonjs/types/WriteNutrition.js +0 -18
  289. package/lib/commonjs/types/WriteNutrition.js.map +0 -1
  290. package/lib/commonjs/utils/getNativeModule.js +0 -29
  291. package/lib/commonjs/utils/getNativeModule.js.map +0 -1
  292. package/lib/commonjs/utils/getRookModule.js +0 -28
  293. package/lib/commonjs/utils/getRookModule.js.map +0 -1
  294. package/lib/commonjs/utils/isModuleReady.js.map +0 -1
  295. package/lib/commonjs/utils/isRunningOnAndroid.js +0 -15
  296. package/lib/commonjs/utils/isRunningOnAndroid.js.map +0 -1
  297. package/lib/commonjs/utils/isRunningOniOS.js +0 -15
  298. package/lib/commonjs/utils/isRunningOniOS.js.map +0 -1
  299. package/lib/commonjs/utils/isValidDate.js.map +0 -1
  300. package/lib/commonjs/utils/nativeModules.js +0 -29
  301. package/lib/commonjs/utils/nativeModules.js.map +0 -1
  302. package/lib/commonjs/utils/packageInfo.js +0 -13
  303. package/lib/commonjs/utils/packageInfo.js.map +0 -1
  304. package/lib/module/context/index.js +0 -2
  305. package/lib/module/context/index.js.map +0 -1
  306. package/lib/module/hooks/index.js +0 -11
  307. package/lib/module/hooks/index.js.map +0 -1
  308. package/lib/module/types/DiagnosticState.js +0 -2
  309. package/lib/module/types/DiagnosticState.js.map +0 -1
  310. package/lib/module/utils/getNativeModule.js +0 -23
  311. package/lib/module/utils/getNativeModule.js.map +0 -1
  312. package/lib/module/utils/getRookModule.js +0 -22
  313. package/lib/module/utils/getRookModule.js.map +0 -1
  314. package/lib/module/utils/nativeModules.js +0 -23
  315. package/lib/module/utils/nativeModules.js.map +0 -1
  316. package/lib/module/utils/packageInfo.js +0 -7
  317. package/lib/module/utils/packageInfo.js.map +0 -1
  318. package/lib/typescript/src/context/index.d.ts +0 -2
  319. package/lib/typescript/src/context/index.d.ts.map +0 -1
  320. package/lib/typescript/src/hooks/index.d.ts +0 -11
  321. package/lib/typescript/src/hooks/index.d.ts.map +0 -1
  322. package/lib/typescript/src/types/DiagnosticState.d.ts +0 -13
  323. package/lib/typescript/src/types/DiagnosticState.d.ts.map +0 -1
  324. package/lib/typescript/src/utils/getNativeModule.d.ts +0 -10
  325. package/lib/typescript/src/utils/getNativeModule.d.ts.map +0 -1
  326. package/lib/typescript/src/utils/getRookModule.d.ts +0 -9
  327. package/lib/typescript/src/utils/getRookModule.d.ts.map +0 -1
  328. package/lib/typescript/src/utils/nativeModules.d.ts +0 -24
  329. package/lib/typescript/src/utils/nativeModules.d.ts.map +0 -1
  330. package/lib/typescript/src/utils/packageInfo.d.ts +0 -6
  331. package/lib/typescript/src/utils/packageInfo.d.ts.map +0 -1
  332. package/react-native-rook-sdk.podspec +0 -45
package/ios/RookSdk.mm CHANGED
@@ -1,167 +1,423 @@
1
1
  #import "RookSdk.h"
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];
12
- }
13
- }
2
+ #import "RNRookSdk-Swift.h"
14
3
 
15
- NSString * _Nullable tryConvertToString(id _Nullable value) {
16
- if ([value isKindOfClass:[NSString class]]) {
17
- return (NSString *)value;
18
- }
19
-
20
- return nil;
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;
21
13
  }
22
14
 
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;
32
-
33
- return [NSError errorWithDomain:@"com.mydomain.MyApp" code:500 userInfo:errorInfo];
15
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
16
+ (const facebook::react::ObjCTurboModule::InitParams &)params
17
+ {
18
+ return std::make_shared<facebook::react::NativeRookSdkSpecJSI>(params);
34
19
  }
35
20
 
36
- // MARK: - Module
37
- @implementation RookSdk
21
+ + (NSString *)moduleName
38
22
  {
39
- bool hasListeners;
23
+ return @"RNRookSdk";
40
24
  }
41
25
 
42
- RCT_EXPORT_MODULE()
43
-
44
- -(void)startObserving {
45
- hasListeners = YES;
46
-
47
- NSLog(@"Hay alguien escuchando");
26
+ - (id) init {
27
+ if (self = [super init]) {
28
+ sources = [RookSources new];
29
+ entry = [RookEntry new];
30
+ config = [RookConfiguration new];
31
+ bg = [RookBackground new];
32
+ perm = [RookPermissions new];
33
+ data = [RookData new];
34
+ sync = [RookSync new];
35
+ shouldEmitEvent = NO;
36
+ }
48
37
 
49
- [[NSNotificationCenter defaultCenter] addObserver:self
50
- selector:@selector(receiveTestNotification:)
51
- name:@"kRookErrorBackground"
38
+ return self;
39
+ }
40
+
41
+ - (void)initialize {
42
+ [[NSNotificationCenter defaultCenter] addObserver:self
43
+ selector:@selector(handleErrorBackground:)
44
+ name:entry.EVENT_NAME
52
45
  object:nil];
46
+ shouldEmitEvent = YES;
53
47
  }
54
48
 
55
- // Will be called when this module's last listener is removed, or on dealloc.
56
- -(void)stopObserving {
57
- hasListeners = NO;
49
+ - (void)handleErrorBackground:(NSNotification *)notification {
50
+ NSDictionary *data = notification.userInfo;
58
51
 
59
- [[NSNotificationCenter defaultCenter] removeObserver:self];
52
+ if (data) {
53
+ NSError *error = data[@"Error"];
54
+
55
+ [self emitOnRookMessage:@{
56
+ @"type": @"ROOK_BACKGROUND_IOS_ERROR",
57
+ @"value": @(NO),
58
+ @"message": error ? error.localizedDescription : @"An error occurred in the iOS background process"
59
+ }];
60
+ }
60
61
  }
61
62
 
62
- - (NSArray<NSString *> *)supportedEvents {
63
- return @[@"ROOK_NOTIFICATION"];
63
+ -(void)invalidate {
64
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
65
+ shouldEmitEvent = NO;
64
66
  }
65
67
 
66
- // The above code is an Objective-C method that receives a notification and checks if the notification
67
- // name is "kRookErrorBackground". If it is, it extracts information from the notification's userInfo
68
- // dictionary, specifically an error object. It then creates a dictionary message containing the type,
69
- // message, and code extracted from the error object. Finally, if there are listeners registered, it
70
- // sends an event with the message dictionary to a specific event name "ROOK_NOTIFICATION".
71
- - (void) receiveTestNotification:(NSNotification *) notification
72
- {
73
- if ([[notification name] isEqualToString:@"kRookErrorBackground"]) {
74
- NSDictionary<NSString*, NSError *> *notificationInfo = [[notification userInfo] mutableCopy];
75
-
76
- NSMutableDictionary *message = [[NSMutableDictionary alloc] init];
77
- message[@"type"] = @"ROOK_APPLE_HEALTH_BACKGROUND_ERROR";
78
- message[@"message"] = notificationInfo[@"Error"].localizedDescription;
79
- message[@"code"] = notificationInfo[@"Error"].description;
80
-
81
- if (hasListeners)
82
- [self sendEventWithName:@"ROOK_NOTIFICATION" body: message];
83
- }
68
+ - (void)isNotiOSSupported:(nonnull RCTPromiseRejectBlock)reject{
69
+ reject(@"1001", @"This method is only available in android", nil);
84
70
  }
85
71
 
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
- */
101
- RCT_EXPORT_METHOD(initRook:(NSDictionary *) data
102
- resolve:(RCTPromiseResolveBlock)resolve
103
- reject:(RCTPromiseRejectBlock)reject) {
72
+ - (void)isNotiOSCBSupported: (nonnull RCTResponseSenderBlock)cb {
73
+ NSDictionary *errorInfo = @{
74
+ @"code": @"1001",
75
+ @"message": @"An error ocurred with SDK try again"
76
+ };
104
77
 
105
- bool enableBackground = [RCTConvert BOOL:data[@"enableBackground"]];
78
+ cb(@[errorInfo, @NO]);
79
+ }
80
+
81
+ - (void)syncSHTodayCaloriesCount:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
82
+ [self isNotiOSSupported:reject];
83
+ }
84
+
85
+ - (void)syncTodaySamsungHealthStepsCount:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
86
+ [self isNotiOSSupported:reject];
87
+ }
88
+
89
+ - (void)cancelBackgroundSync:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
90
+ [self isNotiOSSupported:reject];
91
+ }
92
+
93
+ - (void)isBackgroundSyncEnabled:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
94
+ [self isNotiOSSupported:reject];
95
+ }
96
+
97
+ - (void)getHealthConnectActivityEvents:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
98
+ [self isNotiOSSupported:reject];
99
+ }
100
+
101
+
102
+ - (void)getHealthConnectBodySummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
103
+ [self isNotiOSSupported:reject];
104
+ }
105
+
106
+
107
+ - (void)getHealthConnectPhysicalSummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
108
+ [self isNotiOSSupported:reject];
109
+ }
110
+
111
+
112
+ - (void)getHealthConnectSleepSummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
113
+ [self isNotiOSSupported:reject];
114
+ }
115
+
116
+
117
+ - (void)getSamsungActivityEvents:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
118
+ [self isNotiOSSupported:reject];
119
+ }
120
+
121
+
122
+ - (void)getSamsungBodySummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
123
+ [self isNotiOSSupported:reject];
124
+ }
125
+
126
+
127
+ - (void)getSamsungPhysicalSummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
128
+ [self isNotiOSSupported:reject];
129
+ }
130
+
131
+
132
+ - (void)getSamsungSleepSummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
133
+ [self isNotiOSSupported:reject];
134
+ }
135
+
136
+ - (void)disableSamsungSync:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
137
+ [self isNotiOSSupported:reject];
138
+ }
139
+
140
+ - (void)enableSamsungSync:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
141
+ [self isNotiOSSupported:reject];
142
+ }
143
+
144
+ - (void)isSamsungSyncEnabled:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
145
+ [self isNotiOSSupported:reject];
146
+ }
147
+
148
+ - (void)disableBackgroundAndroidSteps:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
149
+ [self isNotiOSSupported:reject];
150
+ }
151
+
152
+ - (void)enableBackgroundAndroidSteps:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
153
+ [self isNotiOSSupported:reject];
154
+ }
155
+
156
+ - (void)isBackgroundAndroidStepsActive:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
157
+ [self isNotiOSSupported:reject];
158
+ }
159
+
160
+ - (void)isStepsAvailable:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
161
+ [self isNotiOSSupported:reject];
162
+ }
163
+
164
+ - (void)syncTodayAndroidStepsCount:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
165
+ [self isNotiOSSupported:reject];
166
+ }
167
+
168
+ - (void)syncTodayHealthConnectStepsCount:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
169
+ [self isNotiOSSupported:reject];
170
+ }
171
+
172
+ - (void)androidHasBackgroundPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
173
+ [self isNotiOSSupported:reject];
174
+ }
175
+
176
+ - (void)checkHealthConnectAvailability:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
177
+ [self isNotiOSSupported:reject];
178
+ }
179
+
180
+ - (void)checkHealthConnectBackgroundReadStatus:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
181
+ [self isNotiOSSupported:reject];
182
+ }
183
+
184
+ - (void)checkSamsungAvailability:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
185
+ [self isNotiOSSupported:reject];
186
+ }
187
+
188
+ - (void)healthConnectHasPartialPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
189
+ [self isNotiOSSupported:reject];
190
+ }
191
+
192
+ - (void)healthConnectHasPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
193
+ [self isNotiOSSupported:reject];
194
+ }
195
+
196
+ - (void)openHealthConnectSettings:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
197
+ [self isNotiOSSupported:reject];
198
+ }
199
+
200
+ - (void)requestAndroidBackgroundPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
201
+ [self isNotiOSSupported:reject];
202
+ }
203
+
204
+ - (void)requestHealthConnectPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
205
+ [self isNotiOSSupported:reject];
206
+ }
207
+
208
+ - (void)requestSamsungHealthPermissions:(nonnull NSArray *)permissions resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
209
+ [self isNotiOSSupported:reject];
210
+ }
211
+
212
+
213
+ - (void)revokeHealthConnectPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
214
+ [self isNotiOSSupported:reject];
215
+ }
216
+
217
+
218
+ - (void)samsungHealthHasPartialPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
219
+ [self isNotiOSSupported:reject];
220
+ }
221
+
222
+
223
+ - (void)samsungHealthHasPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
224
+ [self isNotiOSSupported:reject];
225
+ }
226
+
227
+ - (void)shSync:(BOOL)enableLogs cb:(nonnull RCTResponseSenderBlock)cb {
228
+ [self isNotiOSCBSupported:cb];
229
+ }
230
+
231
+
232
+ - (void)shSyncByDate:(nonnull NSString *)date cb:(nonnull RCTResponseSenderBlock)cb {
233
+ [self isNotiOSCBSupported:cb];
234
+ }
235
+
236
+
237
+ - (void)shSyncByDefinition:(nonnull NSString *)summary date:(nonnull NSString *)date cb:(nonnull RCTResponseSenderBlock)cb {
238
+ [self isNotiOSCBSupported:cb];
239
+ }
240
+
241
+
242
+ - (void)shSyncEvent:(nonnull NSString *)date event:(nonnull NSString *)event resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
243
+ [self isNotiOSSupported:reject];
244
+ }
245
+
246
+ - (void)getSHTodayHeartRate:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
247
+ [self isNotiOSSupported:reject];
248
+ }
249
+
250
+ - (void)shouldRequestAndroidBackgroundPermissions:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
251
+ [self isNotiOSSupported:reject];
252
+ }
253
+
254
+ - (void)writeHealthConnectMealData:(JS::NativeRookSdk::HCMealData &)data resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
255
+ [self isNotiOSSupported:reject];
256
+ }
257
+
258
+ - (void)scheduleBackgroundSync:(nonnull NSNumber *)enableLogs resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
259
+ [self isNotiOSSupported:reject];
260
+ }
261
+
262
+ - (void)getHealthConnectDiagnosticState:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
263
+ [self isNotiOSSupported:reject];
264
+ }
265
+
266
+
267
+ - (void)getSamsungHealthDiagnosticState:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
268
+ [self isNotiOSSupported:reject];
269
+ }
270
+
271
+ - (void)getAuthorizedDataSourcesV2:(nonnull NSString *)userid resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
272
+ [sources getAuthorizedDataSourcesV2:userid resolve:resolve reject:reject];
273
+ }
274
+
275
+ - (void)getDataSourceAuthorizer:(JS::NativeRookSdk::DataSourceProps &)props resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
106
276
 
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];
277
+ NSMutableDictionary *dict = [NSMutableDictionary new];
278
+ dict[@"dataSource"] = props.dataSource();
279
+ dict[@"redirectURL"] = props.redirectURL();
280
+ dict[@"userID"] = props.userID();
113
281
 
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();
282
+ [sources getDataSourceAuthorizer:dict resolve:resolve reject:reject];
283
+ }
284
+
285
+ - (void)initRook:(JS::NativeRookSdk::RookConfig &)options resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
286
+ NSMutableDictionary *dict = [NSMutableDictionary new];
287
+ dict[@"secret"] = options.secret();
288
+ dict[@"environment"] = options.environment();
289
+ dict[@"clientUUID"] = options.clientUUID();
290
+ dict[@"bundleId"] = options.bundleId();
291
+ dict[@"enableBackground"] = @(options.enableBackground());
292
+
293
+ [entry initRook:dict resolve:resolve reject:reject];
294
+ }
295
+
296
+ - (void)revokeDataSource:(nonnull NSString *)userid type:(nonnull NSString *)type resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
297
+ [sources revokeDataSource:userid source:type resolve:resolve reject:reject];
298
+ }
299
+
300
+ - (void)getUserID:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
301
+ [config getUserID:resolve reject:reject];
302
+ }
303
+
304
+
305
+ - (void)removeUserFromRook:(nonnull NSArray *)sources resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
306
+ [config removeUserFromRook:resolve reject:reject];
307
+ }
308
+
309
+
310
+ - (void)syncUserTimeZone:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
311
+ [config syncUserTimeZone:resolve reject:reject];
312
+ }
313
+
314
+
315
+ - (void)updateUserID:(nonnull NSString *)userID resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
316
+ [config updateUserID:userID resolve:resolve reject:reject];
317
+ }
318
+
319
+ - (void)disableBackGroundUpdates:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
320
+ [bg disableBackGroundUpdates:resolve reject:reject];
321
+ }
322
+
323
+
324
+ - (void)enableBackGroundUpdates:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
325
+ [bg enableBackGroundUpdates:resolve reject:reject];
326
+ }
327
+
328
+
329
+ - (void)isBackgroundUpdatesEnabled:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
330
+ [bg isBackgroundUpdatesEnabled:resolve reject:reject];
331
+ }
332
+
333
+ - (void)appleHealthHasPermissions:(nonnull NSString *)param resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
334
+ [perm checkPermissionsStatus:param resolve:resolve reject:reject];
335
+ }
336
+
337
+ - (void)openAppleHealthSettings:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
338
+ [perm openAppleHealthSettings:resolve reject:reject];
339
+ }
340
+
341
+ - (void)requestAppleHealthPermissions:(nonnull NSArray *)permissions resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
342
+ [perm requestAppleHealthPermissions:permissions resolve:resolve reject:reject];
343
+ }
344
+
345
+ - (void)getAppleHealthActivityEvents:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
346
+ [data getAppleHealthActivityEvents:date resolve:resolve reject:reject];
347
+ }
348
+
349
+
350
+ - (void)getAppleHealthBodySummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
351
+ [data getAppleHealthBodySummary:date resolve:resolve reject:reject];
352
+ }
353
+
354
+
355
+ - (void)getAppleHealthPhysicalSummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
356
+ [data getAppleHealthPhysicalSummary:date resolve:resolve reject:reject];
357
+ }
358
+
359
+
360
+ - (void)getAppleHealthSleepSummary:(nonnull NSString *)date resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
361
+ [data getAppleHealthSleepSummary:date resolve:resolve reject:reject];
362
+ }
363
+
364
+ - (void)getTodayHeartRate:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
365
+ [data getTodayHeartRate:resolve reject:reject];
366
+ }
367
+
368
+ - (void)getTodayAppleHealthSteps:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
369
+ [sync getTodayAppleHealthSteps:resolve reject:reject];
370
+ }
371
+
372
+ - (void)syncTodayCaloriesCount:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
373
+ [sync syncTodayCaloriesCount:resolve reject:reject];
374
+ }
375
+
376
+ - (void)sync:(nonnull RCTResponseSenderBlock)cb {
377
+ [sync sync:cb];
378
+ }
379
+
380
+
381
+ - (void)syncByDate:(nonnull NSString *)date cb:(nonnull RCTResponseSenderBlock)cb {
382
+ [sync syncByDate:date callback:cb];
383
+ }
384
+
385
+
386
+ - (void)syncByDefinition:(nonnull NSString *)summary date:(nonnull NSString *)date cb:(nonnull RCTResponseSenderBlock)cb {
387
+ [sync syncByDefinition:summary syncDate:date callback:cb];
388
+ }
389
+
390
+
391
+ - (void)syncEvent:(nonnull NSString *)date event:(nonnull NSString *)event resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
392
+ [sync syncEvent:date event:event resolve:resolve reject:reject];
393
+ }
394
+
395
+ - (void)sendMessage:(JS::NativeRookSdk::Message &)message resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
396
+
397
+ if (shouldEmitEvent) {
398
+ NSMutableDictionary *messageInfo = [[NSMutableDictionary alloc] init];
399
+ messageInfo[@"type"] = message.type();
400
+ messageInfo[@"value"] = @(message.value());
133
401
 
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;
402
+ if (message.message().length > 0) {
403
+ messageInfo[@"message"] = message.message();
140
404
  }
141
405
 
142
-
143
- resolve(@(result));
144
- }];
145
-
406
+ [self emitOnRookMessage:messageInfo];
407
+ }
146
408
  }
147
409
 
410
+ - (void)requestAppleWriteNutritionPermission:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
411
+ [perm requestWriteNutritionPermission:resolve reject:reject];
412
+ }
148
413
 
414
+ - (void)getDiagnosticState:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
415
+ [config getDiagnosticState:resolve reject:reject];
416
+ }
149
417
 
150
- // MARK: - RN Broadcast
151
-
152
- /**
153
- * Internal method to send messages to broadcast channel
154
- *
155
- * @param resolve A block called with a boolean value indicating whether the result is.
156
- * @param reject A block called if an error occurs, such as Apple Health not being installed.
157
- */
158
- RCT_EXPORT_METHOD(sendMessageToBroadcast: (NSDictionary *) message
159
- resolve: (RCTPromiseResolveBlock) resolve
160
- reject: (RCTPromiseRejectBlock) reject) {
161
- if(hasListeners) {
162
- [self sendEventWithName:@"ROOK_NOTIFICATION" body:message];
163
- }
418
+ - (void)writeAppleHealthMealData:(nonnull NSDictionary *)meal resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
419
+ [data writeAppleHealthMealData:meal resolve:resolve reject:reject];
164
420
  }
165
- @end
166
421
 
167
422
 
423
+ @end