@developer_tribe/react-native-comnyx 0.6.2 → 0.7.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 (474) hide show
  1. package/Comnyx.podspec +1 -1
  2. package/README.md +192 -16
  3. package/android/app/build/generated/source/codegen/RCTAppDependencyProvider.h +25 -0
  4. package/android/app/build/generated/source/codegen/RCTAppDependencyProvider.mm +55 -0
  5. package/android/app/build/generated/source/codegen/RCTModulesConformingToProtocolsProvider.h +18 -0
  6. package/android/app/build/generated/source/codegen/RCTModulesConformingToProtocolsProvider.mm +33 -0
  7. package/android/app/build/generated/source/codegen/RCTThirdPartyComponentsProvider.h +16 -0
  8. package/android/app/build/generated/source/codegen/RCTThirdPartyComponentsProvider.mm +23 -0
  9. package/android/app/build/generated/source/codegen/ReactAppDependencyProvider.podspec +34 -0
  10. package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeAsyncStorageModuleSpec.java +59 -0
  11. package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +36 -0
  12. package/android/app/build/generated/source/codegen/jni/RNComnyxSpec-generated.cpp +22 -0
  13. package/android/app/build/generated/source/codegen/jni/RNComnyxSpec.h +24 -0
  14. package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI-generated.cpp +17 -0
  15. package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI.h +19 -0
  16. package/android/app/build/generated/source/codegen/jni/react/renderer/components/rnasyncstorage/rnasyncstorageJSI-generated.cpp +72 -0
  17. package/android/app/build/generated/source/codegen/jni/react/renderer/components/rnasyncstorage/rnasyncstorageJSI.h +116 -0
  18. package/android/app/build/generated/source/codegen/jni/rnasyncstorage-generated.cpp +62 -0
  19. package/android/app/build/generated/source/codegen/jni/rnasyncstorage.h +31 -0
  20. package/android/build.gradle +13 -1
  21. package/android/generated/RCTAppDependencyProvider.h +25 -0
  22. package/android/generated/RCTAppDependencyProvider.mm +55 -0
  23. package/android/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  24. package/android/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  25. package/android/generated/RCTThirdPartyComponentsProvider.h +16 -0
  26. package/android/generated/RCTThirdPartyComponentsProvider.mm +23 -0
  27. package/android/generated/ReactAppDependencyProvider.podspec +34 -0
  28. package/android/generated/jni/RNComnyxSpec-generated.cpp +1 -11
  29. package/android/generated/jni/RNComnyxSpec.h +0 -7
  30. package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI-generated.cpp +0 -11
  31. package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI.h +0 -52
  32. package/android/src/main/AndroidManifestNew.xml +10 -0
  33. package/android/src/main/java/com/comnyx/ComnyxModule.kt +213 -5
  34. package/android/src/main/java/com/comnyx/ComnyxPackage.kt +10 -6
  35. package/android/src/main/java/com/comnyx/src/messaging/ComnyxMessaging.kt +25 -0
  36. package/android/src/main/java/com/comnyx/src/messaging/firebase/FCM.kt +38 -0
  37. package/android/src/main/java/com/comnyx/src/messaging/firebase/FirebaseMessagingService.kt +45 -0
  38. package/android/src/main/java/com/comnyx/src/messaging/notifications/NotificationsService.kt +99 -0
  39. package/ios/APNService.swift +74 -0
  40. package/ios/Comnyx-Bridging-Header.h +17 -0
  41. package/ios/Comnyx.m +18 -0
  42. package/ios/Comnyx.swift +117 -0
  43. package/ios/ComnyxMessaging.swift +84 -0
  44. package/ios/PushService.swift +7 -0
  45. package/lib/commonjs/NativeComnyx.js +15 -0
  46. package/lib/commonjs/NativeComnyx.js.map +1 -0
  47. package/lib/commonjs/api/api.js +14 -4
  48. package/lib/commonjs/api/api.js.map +1 -1
  49. package/lib/commonjs/api/customers.js +3 -8
  50. package/lib/commonjs/api/customers.js.map +1 -1
  51. package/lib/commonjs/api/index.js +1 -1
  52. package/lib/commonjs/components/AppText.js +1 -1
  53. package/lib/commonjs/components/AppText.js.map +1 -1
  54. package/lib/commonjs/components/ChatList.js +6 -2
  55. package/lib/commonjs/components/ChatList.js.map +1 -1
  56. package/lib/commonjs/components/CustomerForm.js +2 -16
  57. package/lib/commonjs/components/CustomerForm.js.map +1 -1
  58. package/lib/commonjs/components/EmptyList.js +1 -1
  59. package/lib/commonjs/components/EmptyList.js.map +1 -1
  60. package/lib/commonjs/components/MessageInput.js +1 -1
  61. package/lib/commonjs/components/MessageInput.js.map +1 -1
  62. package/lib/commonjs/constants/viewabilityConfig.js.map +1 -0
  63. package/lib/commonjs/hooks/isRtl.js +1 -1
  64. package/lib/commonjs/hooks/useLocalize.js +1 -1
  65. package/lib/commonjs/hooks/useLocalize.js.map +1 -1
  66. package/lib/commonjs/hooks/usePolling.js +1 -1
  67. package/lib/commonjs/hooks/usePolling.js.map +1 -1
  68. package/lib/commonjs/hooks/useTheme.js +1 -1
  69. package/lib/commonjs/hooks/useTheme.js.map +1 -1
  70. package/lib/commonjs/index.js +12 -12
  71. package/lib/commonjs/index.js.map +1 -1
  72. package/lib/commonjs/notifications/index.js +22 -0
  73. package/lib/commonjs/notifications/index.js.map +1 -0
  74. package/lib/commonjs/{Accumulator.js → register/Accumulator.js} +13 -1
  75. package/lib/commonjs/register/Accumulator.js.map +1 -0
  76. package/lib/commonjs/{collectData.js → register/collectData.js} +2 -0
  77. package/lib/commonjs/register/collectData.js.map +1 -0
  78. package/lib/commonjs/register/index.js +17 -0
  79. package/lib/commonjs/register/index.js.map +1 -0
  80. package/lib/commonjs/register/init.js +14 -0
  81. package/lib/commonjs/register/init.js.map +1 -0
  82. package/lib/commonjs/register/login.js +25 -0
  83. package/lib/commonjs/register/login.js.map +1 -0
  84. package/lib/commonjs/register/logout.js +19 -0
  85. package/lib/commonjs/register/logout.js.map +1 -0
  86. package/lib/commonjs/{store.js → store/store.js} +3 -2
  87. package/lib/commonjs/store/store.js.map +1 -0
  88. package/lib/commonjs/support/ComnyxSupport.js +118 -0
  89. package/lib/commonjs/support/ComnyxSupport.js.map +1 -0
  90. package/lib/commonjs/support/index.js +13 -0
  91. package/lib/commonjs/support/index.js.map +1 -0
  92. package/lib/commonjs/utils/scalingUtils.js +1 -1
  93. package/lib/module/NativeComnyx.js +11 -0
  94. package/lib/module/NativeComnyx.js.map +1 -0
  95. package/lib/module/api/api.js +11 -4
  96. package/lib/module/api/api.js.map +1 -1
  97. package/lib/module/api/customers.js +3 -7
  98. package/lib/module/api/customers.js.map +1 -1
  99. package/lib/module/api/index.js +1 -1
  100. package/lib/module/api/index.js.map +1 -1
  101. package/lib/module/components/AppText.js +1 -1
  102. package/lib/module/components/AppText.js.map +1 -1
  103. package/lib/module/components/ChatList.js +6 -2
  104. package/lib/module/components/ChatList.js.map +1 -1
  105. package/lib/module/components/CustomerForm.js +3 -17
  106. package/lib/module/components/CustomerForm.js.map +1 -1
  107. package/lib/module/components/EmptyList.js +1 -1
  108. package/lib/module/components/EmptyList.js.map +1 -1
  109. package/lib/module/components/MessageInput.js +1 -1
  110. package/lib/module/components/MessageInput.js.map +1 -1
  111. package/lib/module/constants/viewabilityConfig.js.map +1 -0
  112. package/lib/module/hooks/isRtl.js +1 -1
  113. package/lib/module/hooks/isRtl.js.map +1 -1
  114. package/lib/module/hooks/useLocalize.js +1 -1
  115. package/lib/module/hooks/useLocalize.js.map +1 -1
  116. package/lib/module/hooks/usePolling.js +1 -1
  117. package/lib/module/hooks/usePolling.js.map +1 -1
  118. package/lib/module/hooks/useTheme.js +1 -1
  119. package/lib/module/hooks/useTheme.js.map +1 -1
  120. package/lib/module/index.js +9 -5
  121. package/lib/module/index.js.map +1 -1
  122. package/lib/module/notifications/index.js +20 -0
  123. package/lib/module/notifications/index.js.map +1 -0
  124. package/lib/module/{Accumulator.js → register/Accumulator.js} +12 -1
  125. package/lib/module/register/Accumulator.js.map +1 -0
  126. package/lib/module/{collectData.js → register/collectData.js} +2 -0
  127. package/lib/module/register/collectData.js.map +1 -0
  128. package/lib/module/register/index.js +13 -0
  129. package/lib/module/register/index.js.map +1 -0
  130. package/lib/module/register/init.js +10 -0
  131. package/lib/module/register/init.js.map +1 -0
  132. package/lib/module/register/login.js +21 -0
  133. package/lib/module/register/login.js.map +1 -0
  134. package/lib/module/register/logout.js +15 -0
  135. package/lib/module/register/logout.js.map +1 -0
  136. package/lib/module/{store.js → store/store.js} +2 -2
  137. package/lib/module/store/store.js.map +1 -0
  138. package/lib/module/support/ComnyxSupport.js +114 -0
  139. package/lib/module/support/ComnyxSupport.js.map +1 -0
  140. package/lib/module/support/index.js +4 -0
  141. package/lib/module/support/index.js.map +1 -0
  142. package/lib/module/utils/scalingUtils.js +1 -1
  143. package/lib/module/utils/scalingUtils.js.map +1 -1
  144. package/lib/typescript/jest.config.d.ts +4 -0
  145. package/lib/typescript/jest.config.d.ts.map +1 -0
  146. package/lib/typescript/setup-jest.d.ts +1 -0
  147. package/lib/typescript/setup-jest.d.ts.map +1 -0
  148. package/lib/typescript/src/NativeComnyx.d.ts +13 -0
  149. package/lib/typescript/src/NativeComnyx.d.ts.map +1 -0
  150. package/lib/typescript/src/api/api.d.ts +7 -0
  151. package/lib/typescript/src/api/api.d.ts.map +1 -0
  152. package/lib/typescript/src/api/conversations.d.ts.map +1 -0
  153. package/lib/typescript/src/api/customers.d.ts +5 -0
  154. package/lib/typescript/src/api/customers.d.ts.map +1 -0
  155. package/lib/typescript/{commonjs/src → src}/api/index.d.ts +1 -1
  156. package/lib/typescript/src/api/index.d.ts.map +1 -0
  157. package/lib/typescript/src/api/messages.d.ts.map +1 -0
  158. package/lib/typescript/src/components/AppText.d.ts.map +1 -0
  159. package/lib/typescript/src/components/ChatList.d.ts +5 -0
  160. package/lib/typescript/src/components/ChatList.d.ts.map +1 -0
  161. package/lib/typescript/src/components/CustomAlert.d.ts.map +1 -0
  162. package/lib/typescript/src/components/CustomerForm.d.ts +5 -0
  163. package/lib/typescript/src/components/CustomerForm.d.ts.map +1 -0
  164. package/lib/typescript/src/components/EmptyList.d.ts.map +1 -0
  165. package/lib/typescript/src/components/InitFailed.d.ts.map +1 -0
  166. package/lib/typescript/src/components/MessageInput.d.ts.map +1 -0
  167. package/lib/typescript/src/components/MessageItem.d.ts.map +1 -0
  168. package/lib/typescript/src/components/ScaledSheet.d.ts.map +1 -0
  169. package/lib/typescript/src/constants/activeOpacity.d.ts.map +1 -0
  170. package/lib/typescript/src/constants/countries.d.ts.map +1 -0
  171. package/lib/typescript/src/constants/rtl.d.ts.map +1 -0
  172. package/lib/typescript/src/constants/translations.d.ts.map +1 -0
  173. package/lib/typescript/src/constants/viewabilityConfig.d.ts.map +1 -0
  174. package/lib/typescript/src/data/fake/conversations.d.ts.map +1 -0
  175. package/lib/typescript/src/data/fake/customers.d.ts.map +1 -0
  176. package/lib/typescript/src/data/fake/messages.d.ts.map +1 -0
  177. package/lib/typescript/src/hooks/isRtl.d.ts.map +1 -0
  178. package/lib/typescript/src/hooks/useLocalize.d.ts.map +1 -0
  179. package/lib/typescript/src/hooks/usePolling.d.ts.map +1 -0
  180. package/lib/typescript/src/hooks/useTheme.d.ts.map +1 -0
  181. package/lib/typescript/src/hooks/useThemeColors.d.ts.map +1 -0
  182. package/lib/typescript/src/index.d.ts +6 -0
  183. package/lib/typescript/src/index.d.ts.map +1 -0
  184. package/lib/typescript/src/notifications/index.d.ts +21 -0
  185. package/lib/typescript/src/notifications/index.d.ts.map +1 -0
  186. package/lib/typescript/{commonjs/src → src/register}/Accumulator.d.ts +4 -3
  187. package/lib/typescript/src/register/Accumulator.d.ts.map +1 -0
  188. package/lib/typescript/src/register/collectData.d.ts.map +1 -0
  189. package/lib/typescript/src/register/index.d.ts +11 -0
  190. package/lib/typescript/src/register/index.d.ts.map +1 -0
  191. package/lib/typescript/src/register/init.d.ts +6 -0
  192. package/lib/typescript/src/register/init.d.ts.map +1 -0
  193. package/lib/typescript/src/register/login.d.ts +6 -0
  194. package/lib/typescript/src/register/login.d.ts.map +1 -0
  195. package/lib/typescript/src/register/logout.d.ts +2 -0
  196. package/lib/typescript/src/register/logout.d.ts.map +1 -0
  197. package/lib/typescript/{module/src → src/store}/store.d.ts +6 -4
  198. package/lib/typescript/src/store/store.d.ts.map +1 -0
  199. package/lib/typescript/src/support/ComnyxSupport.d.ts +12 -0
  200. package/lib/typescript/src/support/ComnyxSupport.d.ts.map +1 -0
  201. package/lib/typescript/src/support/index.d.ts +2 -0
  202. package/lib/typescript/src/support/index.d.ts.map +1 -0
  203. package/lib/typescript/src/types/ApiOptions.d.ts.map +1 -0
  204. package/lib/typescript/src/types/Conversation.d.ts.map +1 -0
  205. package/lib/typescript/src/types/Customer.d.ts.map +1 -0
  206. package/lib/typescript/src/types/GlobalTheme.d.ts.map +1 -0
  207. package/lib/typescript/src/types/Language.d.ts.map +1 -0
  208. package/lib/typescript/src/types/LocalizationKeys.d.ts.map +1 -0
  209. package/lib/typescript/src/types/MessageResponse.d.ts.map +1 -0
  210. package/lib/typescript/src/types/Theme.d.ts.map +1 -0
  211. package/lib/typescript/src/utils/date.d.ts.map +1 -0
  212. package/lib/typescript/src/utils/deepMap.d.ts.map +1 -0
  213. package/lib/typescript/src/utils/formatDate.d.ts.map +1 -0
  214. package/lib/typescript/src/utils/scalingUtils.d.ts.map +1 -0
  215. package/package.json +26 -27
  216. package/src/NativeComnyx.ts +13 -5
  217. package/src/api/api.ts +14 -4
  218. package/src/api/customers.ts +3 -8
  219. package/src/api/index.ts +1 -1
  220. package/src/components/AppText.tsx +1 -1
  221. package/src/components/ChatList.tsx +13 -3
  222. package/src/components/CustomerForm.tsx +10 -18
  223. package/src/components/EmptyList.tsx +1 -1
  224. package/src/components/MessageInput.tsx +1 -1
  225. package/src/hooks/isRtl.ts +1 -1
  226. package/src/hooks/useLocalize.ts +1 -1
  227. package/src/hooks/usePolling.ts +1 -1
  228. package/src/hooks/useTheme.ts +1 -1
  229. package/src/index.ts +9 -0
  230. package/src/notifications/index.ts +50 -0
  231. package/src/{Accumulator.ts → register/Accumulator.ts} +14 -2
  232. package/src/{collectData.ts → register/collectData.ts} +1 -0
  233. package/src/register/index.ts +11 -0
  234. package/src/register/init.ts +16 -0
  235. package/src/register/login.ts +24 -0
  236. package/src/register/logout.ts +13 -0
  237. package/src/{store.ts → store/store.ts} +7 -7
  238. package/src/support/ComnyxSupport.tsx +116 -0
  239. package/src/support/index.ts +1 -0
  240. package/src/utils/scalingUtils.ts +1 -1
  241. package/android/generated/java/com/comnyx/NativeComnyxSpec.java +0 -37
  242. package/ios/Comnyx.h +0 -6
  243. package/ios/Comnyx.mm +0 -18
  244. package/ios/generated/RNComnyxSpec/RNComnyxSpec-generated.mm +0 -39
  245. package/ios/generated/RNComnyxSpec/RNComnyxSpec.h +0 -63
  246. package/ios/generated/RNComnyxSpecJSI-generated.cpp +0 -28
  247. package/ios/generated/RNComnyxSpecJSI.h +0 -71
  248. package/lib/commonjs/Accumulator.js.map +0 -1
  249. package/lib/commonjs/App.js +0 -78
  250. package/lib/commonjs/App.js.map +0 -1
  251. package/lib/commonjs/NativeComnyx.ts +0 -8
  252. package/lib/commonjs/__dev__.js +0 -29
  253. package/lib/commonjs/__dev__.js.map +0 -1
  254. package/lib/commonjs/collectData.js.map +0 -1
  255. package/lib/commonjs/components/SizeMatter.js +0 -27
  256. package/lib/commonjs/components/SizeMatter.js.map +0 -1
  257. package/lib/commonjs/package.json +0 -1
  258. package/lib/commonjs/register.js +0 -26
  259. package/lib/commonjs/register.js.map +0 -1
  260. package/lib/commonjs/store.js.map +0 -1
  261. package/lib/commonjs/viewabilityConfig.js.map +0 -1
  262. package/lib/module/Accumulator.js.map +0 -1
  263. package/lib/module/App.js +0 -74
  264. package/lib/module/App.js.map +0 -1
  265. package/lib/module/NativeComnyx.ts +0 -8
  266. package/lib/module/__dev__.js +0 -29
  267. package/lib/module/__dev__.js.map +0 -1
  268. package/lib/module/collectData.js.map +0 -1
  269. package/lib/module/components/SizeMatter.js +0 -23
  270. package/lib/module/components/SizeMatter.js.map +0 -1
  271. package/lib/module/package.json +0 -1
  272. package/lib/module/register.js +0 -22
  273. package/lib/module/register.js.map +0 -1
  274. package/lib/module/store.js.map +0 -1
  275. package/lib/module/viewabilityConfig.js.map +0 -1
  276. package/lib/typescript/commonjs/package.json +0 -1
  277. package/lib/typescript/commonjs/src/Accumulator.d.ts.map +0 -1
  278. package/lib/typescript/commonjs/src/App.d.ts +0 -12
  279. package/lib/typescript/commonjs/src/App.d.ts.map +0 -1
  280. package/lib/typescript/commonjs/src/NativeComnyx.d.ts +0 -7
  281. package/lib/typescript/commonjs/src/NativeComnyx.d.ts.map +0 -1
  282. package/lib/typescript/commonjs/src/__dev__.d.ts +0 -2
  283. package/lib/typescript/commonjs/src/__dev__.d.ts.map +0 -1
  284. package/lib/typescript/commonjs/src/api/api.d.ts +0 -4
  285. package/lib/typescript/commonjs/src/api/api.d.ts.map +0 -1
  286. package/lib/typescript/commonjs/src/api/conversations.d.ts.map +0 -1
  287. package/lib/typescript/commonjs/src/api/customers.d.ts +0 -6
  288. package/lib/typescript/commonjs/src/api/customers.d.ts.map +0 -1
  289. package/lib/typescript/commonjs/src/api/index.d.ts.map +0 -1
  290. package/lib/typescript/commonjs/src/api/messages.d.ts.map +0 -1
  291. package/lib/typescript/commonjs/src/collectData.d.ts.map +0 -1
  292. package/lib/typescript/commonjs/src/components/AppText.d.ts.map +0 -1
  293. package/lib/typescript/commonjs/src/components/ChatList.d.ts +0 -4
  294. package/lib/typescript/commonjs/src/components/ChatList.d.ts.map +0 -1
  295. package/lib/typescript/commonjs/src/components/CustomAlert.d.ts.map +0 -1
  296. package/lib/typescript/commonjs/src/components/CustomerForm.d.ts +0 -4
  297. package/lib/typescript/commonjs/src/components/CustomerForm.d.ts.map +0 -1
  298. package/lib/typescript/commonjs/src/components/EmptyList.d.ts.map +0 -1
  299. package/lib/typescript/commonjs/src/components/InitFailed.d.ts.map +0 -1
  300. package/lib/typescript/commonjs/src/components/MessageInput.d.ts.map +0 -1
  301. package/lib/typescript/commonjs/src/components/MessageItem.d.ts.map +0 -1
  302. package/lib/typescript/commonjs/src/components/ScaledSheet.d.ts.map +0 -1
  303. package/lib/typescript/commonjs/src/components/SizeMatter.d.ts +0 -7
  304. package/lib/typescript/commonjs/src/components/SizeMatter.d.ts.map +0 -1
  305. package/lib/typescript/commonjs/src/constants/activeOpacity.d.ts.map +0 -1
  306. package/lib/typescript/commonjs/src/constants/countries.d.ts.map +0 -1
  307. package/lib/typescript/commonjs/src/constants/rtl.d.ts.map +0 -1
  308. package/lib/typescript/commonjs/src/constants/translations.d.ts.map +0 -1
  309. package/lib/typescript/commonjs/src/data/fake/conversations.d.ts.map +0 -1
  310. package/lib/typescript/commonjs/src/data/fake/customers.d.ts.map +0 -1
  311. package/lib/typescript/commonjs/src/data/fake/messages.d.ts.map +0 -1
  312. package/lib/typescript/commonjs/src/hooks/isRtl.d.ts.map +0 -1
  313. package/lib/typescript/commonjs/src/hooks/useLocalize.d.ts.map +0 -1
  314. package/lib/typescript/commonjs/src/hooks/usePolling.d.ts.map +0 -1
  315. package/lib/typescript/commonjs/src/hooks/useTheme.d.ts.map +0 -1
  316. package/lib/typescript/commonjs/src/hooks/useThemeColors.d.ts.map +0 -1
  317. package/lib/typescript/commonjs/src/index.d.ts +0 -7
  318. package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
  319. package/lib/typescript/commonjs/src/register.d.ts +0 -6
  320. package/lib/typescript/commonjs/src/register.d.ts.map +0 -1
  321. package/lib/typescript/commonjs/src/store.d.ts +0 -40
  322. package/lib/typescript/commonjs/src/store.d.ts.map +0 -1
  323. package/lib/typescript/commonjs/src/types/ApiOptions.d.ts.map +0 -1
  324. package/lib/typescript/commonjs/src/types/Conversation.d.ts.map +0 -1
  325. package/lib/typescript/commonjs/src/types/Customer.d.ts.map +0 -1
  326. package/lib/typescript/commonjs/src/types/GlobalTheme.d.ts.map +0 -1
  327. package/lib/typescript/commonjs/src/types/Language.d.ts.map +0 -1
  328. package/lib/typescript/commonjs/src/types/LocalizationKeys.d.ts.map +0 -1
  329. package/lib/typescript/commonjs/src/types/MessageResponse.d.ts.map +0 -1
  330. package/lib/typescript/commonjs/src/types/Theme.d.ts.map +0 -1
  331. package/lib/typescript/commonjs/src/utils/date.d.ts.map +0 -1
  332. package/lib/typescript/commonjs/src/utils/deepMap.d.ts.map +0 -1
  333. package/lib/typescript/commonjs/src/utils/formatDate.d.ts.map +0 -1
  334. package/lib/typescript/commonjs/src/utils/scalingUtils.d.ts.map +0 -1
  335. package/lib/typescript/commonjs/src/viewabilityConfig.d.ts.map +0 -1
  336. package/lib/typescript/module/package.json +0 -1
  337. package/lib/typescript/module/src/Accumulator.d.ts +0 -18
  338. package/lib/typescript/module/src/Accumulator.d.ts.map +0 -1
  339. package/lib/typescript/module/src/App.d.ts +0 -12
  340. package/lib/typescript/module/src/App.d.ts.map +0 -1
  341. package/lib/typescript/module/src/NativeComnyx.d.ts +0 -7
  342. package/lib/typescript/module/src/NativeComnyx.d.ts.map +0 -1
  343. package/lib/typescript/module/src/__dev__.d.ts +0 -2
  344. package/lib/typescript/module/src/__dev__.d.ts.map +0 -1
  345. package/lib/typescript/module/src/api/api.d.ts +0 -4
  346. package/lib/typescript/module/src/api/api.d.ts.map +0 -1
  347. package/lib/typescript/module/src/api/conversations.d.ts +0 -7
  348. package/lib/typescript/module/src/api/conversations.d.ts.map +0 -1
  349. package/lib/typescript/module/src/api/customers.d.ts +0 -6
  350. package/lib/typescript/module/src/api/customers.d.ts.map +0 -1
  351. package/lib/typescript/module/src/api/index.d.ts +0 -4
  352. package/lib/typescript/module/src/api/index.d.ts.map +0 -1
  353. package/lib/typescript/module/src/api/messages.d.ts +0 -4
  354. package/lib/typescript/module/src/api/messages.d.ts.map +0 -1
  355. package/lib/typescript/module/src/collectData.d.ts +0 -3
  356. package/lib/typescript/module/src/collectData.d.ts.map +0 -1
  357. package/lib/typescript/module/src/components/AppText.d.ts +0 -14
  358. package/lib/typescript/module/src/components/AppText.d.ts.map +0 -1
  359. package/lib/typescript/module/src/components/ChatList.d.ts +0 -4
  360. package/lib/typescript/module/src/components/ChatList.d.ts.map +0 -1
  361. package/lib/typescript/module/src/components/CustomAlert.d.ts +0 -15
  362. package/lib/typescript/module/src/components/CustomAlert.d.ts.map +0 -1
  363. package/lib/typescript/module/src/components/CustomerForm.d.ts +0 -4
  364. package/lib/typescript/module/src/components/CustomerForm.d.ts.map +0 -1
  365. package/lib/typescript/module/src/components/EmptyList.d.ts +0 -2
  366. package/lib/typescript/module/src/components/EmptyList.d.ts.map +0 -1
  367. package/lib/typescript/module/src/components/InitFailed.d.ts +0 -6
  368. package/lib/typescript/module/src/components/InitFailed.d.ts.map +0 -1
  369. package/lib/typescript/module/src/components/MessageInput.d.ts +0 -5
  370. package/lib/typescript/module/src/components/MessageInput.d.ts.map +0 -1
  371. package/lib/typescript/module/src/components/MessageItem.d.ts +0 -6
  372. package/lib/typescript/module/src/components/MessageItem.d.ts.map +0 -1
  373. package/lib/typescript/module/src/components/ScaledSheet.d.ts +0 -2
  374. package/lib/typescript/module/src/components/ScaledSheet.d.ts.map +0 -1
  375. package/lib/typescript/module/src/components/SizeMatter.d.ts +0 -7
  376. package/lib/typescript/module/src/components/SizeMatter.d.ts.map +0 -1
  377. package/lib/typescript/module/src/constants/activeOpacity.d.ts +0 -2
  378. package/lib/typescript/module/src/constants/activeOpacity.d.ts.map +0 -1
  379. package/lib/typescript/module/src/constants/countries.d.ts +0 -7
  380. package/lib/typescript/module/src/constants/countries.d.ts.map +0 -1
  381. package/lib/typescript/module/src/constants/rtl.d.ts +0 -2
  382. package/lib/typescript/module/src/constants/rtl.d.ts.map +0 -1
  383. package/lib/typescript/module/src/constants/translations.d.ts +0 -4
  384. package/lib/typescript/module/src/constants/translations.d.ts.map +0 -1
  385. package/lib/typescript/module/src/data/fake/conversations.d.ts +0 -5
  386. package/lib/typescript/module/src/data/fake/conversations.d.ts.map +0 -1
  387. package/lib/typescript/module/src/data/fake/customers.d.ts +0 -3
  388. package/lib/typescript/module/src/data/fake/customers.d.ts.map +0 -1
  389. package/lib/typescript/module/src/data/fake/messages.d.ts +0 -3
  390. package/lib/typescript/module/src/data/fake/messages.d.ts.map +0 -1
  391. package/lib/typescript/module/src/hooks/isRtl.d.ts +0 -2
  392. package/lib/typescript/module/src/hooks/isRtl.d.ts.map +0 -1
  393. package/lib/typescript/module/src/hooks/useLocalize.d.ts +0 -3
  394. package/lib/typescript/module/src/hooks/useLocalize.d.ts.map +0 -1
  395. package/lib/typescript/module/src/hooks/usePolling.d.ts +0 -2
  396. package/lib/typescript/module/src/hooks/usePolling.d.ts.map +0 -1
  397. package/lib/typescript/module/src/hooks/useTheme.d.ts +0 -3
  398. package/lib/typescript/module/src/hooks/useTheme.d.ts.map +0 -1
  399. package/lib/typescript/module/src/hooks/useThemeColors.d.ts +0 -3
  400. package/lib/typescript/module/src/hooks/useThemeColors.d.ts.map +0 -1
  401. package/lib/typescript/module/src/index.d.ts +0 -7
  402. package/lib/typescript/module/src/index.d.ts.map +0 -1
  403. package/lib/typescript/module/src/register.d.ts +0 -6
  404. package/lib/typescript/module/src/register.d.ts.map +0 -1
  405. package/lib/typescript/module/src/store.d.ts.map +0 -1
  406. package/lib/typescript/module/src/types/ApiOptions.d.ts +0 -4
  407. package/lib/typescript/module/src/types/ApiOptions.d.ts.map +0 -1
  408. package/lib/typescript/module/src/types/Conversation.d.ts +0 -33
  409. package/lib/typescript/module/src/types/Conversation.d.ts.map +0 -1
  410. package/lib/typescript/module/src/types/Customer.d.ts +0 -39
  411. package/lib/typescript/module/src/types/Customer.d.ts.map +0 -1
  412. package/lib/typescript/module/src/types/GlobalTheme.d.ts +0 -6
  413. package/lib/typescript/module/src/types/GlobalTheme.d.ts.map +0 -1
  414. package/lib/typescript/module/src/types/Language.d.ts +0 -2
  415. package/lib/typescript/module/src/types/Language.d.ts.map +0 -1
  416. package/lib/typescript/module/src/types/LocalizationKeys.d.ts +0 -43
  417. package/lib/typescript/module/src/types/LocalizationKeys.d.ts.map +0 -1
  418. package/lib/typescript/module/src/types/MessageResponse.d.ts +0 -61
  419. package/lib/typescript/module/src/types/MessageResponse.d.ts.map +0 -1
  420. package/lib/typescript/module/src/types/Theme.d.ts +0 -28
  421. package/lib/typescript/module/src/types/Theme.d.ts.map +0 -1
  422. package/lib/typescript/module/src/utils/date.d.ts +0 -7
  423. package/lib/typescript/module/src/utils/date.d.ts.map +0 -1
  424. package/lib/typescript/module/src/utils/deepMap.d.ts +0 -7
  425. package/lib/typescript/module/src/utils/deepMap.d.ts.map +0 -1
  426. package/lib/typescript/module/src/utils/formatDate.d.ts +0 -2
  427. package/lib/typescript/module/src/utils/formatDate.d.ts.map +0 -1
  428. package/lib/typescript/module/src/utils/scalingUtils.d.ts +0 -10
  429. package/lib/typescript/module/src/utils/scalingUtils.d.ts.map +0 -1
  430. package/lib/typescript/module/src/viewabilityConfig.d.ts +0 -5
  431. package/lib/typescript/module/src/viewabilityConfig.d.ts.map +0 -1
  432. package/src/App.tsx +0 -77
  433. package/src/__dev__.ts +0 -22
  434. package/src/components/SizeMatter.tsx +0 -22
  435. package/src/index.tsx +0 -9
  436. package/src/register.ts +0 -34
  437. /package/lib/commonjs/{viewabilityConfig.js → constants/viewabilityConfig.js} +0 -0
  438. /package/lib/module/{viewabilityConfig.js → constants/viewabilityConfig.js} +0 -0
  439. /package/lib/typescript/{commonjs/src → src}/api/conversations.d.ts +0 -0
  440. /package/lib/typescript/{commonjs/src → src}/api/messages.d.ts +0 -0
  441. /package/lib/typescript/{commonjs/src → src}/components/AppText.d.ts +0 -0
  442. /package/lib/typescript/{commonjs/src → src}/components/CustomAlert.d.ts +0 -0
  443. /package/lib/typescript/{commonjs/src → src}/components/EmptyList.d.ts +0 -0
  444. /package/lib/typescript/{commonjs/src → src}/components/InitFailed.d.ts +0 -0
  445. /package/lib/typescript/{commonjs/src → src}/components/MessageInput.d.ts +0 -0
  446. /package/lib/typescript/{commonjs/src → src}/components/MessageItem.d.ts +0 -0
  447. /package/lib/typescript/{commonjs/src → src}/components/ScaledSheet.d.ts +0 -0
  448. /package/lib/typescript/{commonjs/src → src}/constants/activeOpacity.d.ts +0 -0
  449. /package/lib/typescript/{commonjs/src → src}/constants/countries.d.ts +0 -0
  450. /package/lib/typescript/{commonjs/src → src}/constants/rtl.d.ts +0 -0
  451. /package/lib/typescript/{commonjs/src → src}/constants/translations.d.ts +0 -0
  452. /package/lib/typescript/{commonjs/src → src/constants}/viewabilityConfig.d.ts +0 -0
  453. /package/lib/typescript/{commonjs/src → src}/data/fake/conversations.d.ts +0 -0
  454. /package/lib/typescript/{commonjs/src → src}/data/fake/customers.d.ts +0 -0
  455. /package/lib/typescript/{commonjs/src → src}/data/fake/messages.d.ts +0 -0
  456. /package/lib/typescript/{commonjs/src → src}/hooks/isRtl.d.ts +0 -0
  457. /package/lib/typescript/{commonjs/src → src}/hooks/useLocalize.d.ts +0 -0
  458. /package/lib/typescript/{commonjs/src → src}/hooks/usePolling.d.ts +0 -0
  459. /package/lib/typescript/{commonjs/src → src}/hooks/useTheme.d.ts +0 -0
  460. /package/lib/typescript/{commonjs/src → src}/hooks/useThemeColors.d.ts +0 -0
  461. /package/lib/typescript/{commonjs/src → src/register}/collectData.d.ts +0 -0
  462. /package/lib/typescript/{commonjs/src → src}/types/ApiOptions.d.ts +0 -0
  463. /package/lib/typescript/{commonjs/src → src}/types/Conversation.d.ts +0 -0
  464. /package/lib/typescript/{commonjs/src → src}/types/Customer.d.ts +0 -0
  465. /package/lib/typescript/{commonjs/src → src}/types/GlobalTheme.d.ts +0 -0
  466. /package/lib/typescript/{commonjs/src → src}/types/Language.d.ts +0 -0
  467. /package/lib/typescript/{commonjs/src → src}/types/LocalizationKeys.d.ts +0 -0
  468. /package/lib/typescript/{commonjs/src → src}/types/MessageResponse.d.ts +0 -0
  469. /package/lib/typescript/{commonjs/src → src}/types/Theme.d.ts +0 -0
  470. /package/lib/typescript/{commonjs/src → src}/utils/date.d.ts +0 -0
  471. /package/lib/typescript/{commonjs/src → src}/utils/deepMap.d.ts +0 -0
  472. /package/lib/typescript/{commonjs/src → src}/utils/formatDate.d.ts +0 -0
  473. /package/lib/typescript/{commonjs/src → src}/utils/scalingUtils.d.ts +0 -0
  474. /package/src/{viewabilityConfig.ts → constants/viewabilityConfig.ts} +0 -0
@@ -1,23 +1,231 @@
1
1
  package com.comnyx
2
2
 
3
+ import com.comnyx.messaging.ComnyxMessaging
4
+ import com.facebook.react.bridge.Arguments
5
+ import com.facebook.react.bridge.Promise
3
6
  import com.facebook.react.bridge.ReactApplicationContext
7
+ import com.facebook.react.bridge.ReactContext
8
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
9
+ import com.facebook.react.bridge.ReactMethod
10
+ import com.facebook.react.bridge.WritableMap
4
11
  import com.facebook.react.module.annotations.ReactModule
12
+ import com.facebook.react.modules.core.DeviceEventManagerModule
13
+ import com.facebook.react.modules.core.PermissionListener
14
+ import android.util.Log
15
+ import android.Manifest
16
+ import android.content.pm.PackageManager
17
+ import android.os.Build
18
+ import androidx.core.content.ContextCompat
19
+ import androidx.core.app.ActivityCompat
20
+ import android.app.NotificationManager
21
+ import android.content.Context
22
+ import android.content.Intent
23
+ import android.net.Uri
24
+ import android.provider.Settings
5
25
 
6
26
  @ReactModule(name = ComnyxModule.NAME)
7
27
  class ComnyxModule(reactContext: ReactApplicationContext) :
8
- NativeComnyxSpec(reactContext) {
28
+ ReactContextBaseJavaModule(reactContext), PermissionListener {
29
+ private val comnyxMessaging : ComnyxMessaging
30
+ private var pendingPromise: Promise? = null
31
+ private val PERMISSION_REQUEST_CODE = 100
32
+
33
+ init {
34
+ comnyxMessaging = ComnyxMessaging(reactContext)
35
+ __self = this
36
+ }
9
37
 
10
38
  override fun getName(): String {
11
39
  return NAME
12
40
  }
13
41
 
14
- // Example method
15
- // See https://reactnative.dev/docs/native-modules-android
16
- override fun multiply(a: Double, b: Double): Double {
17
- return a * b
42
+ private fun sendEvent(reactContext: ReactContext, eventName: String, params: Any?) {
43
+ reactContext
44
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
45
+ .emit(eventName, params)
46
+ }
47
+
48
+ @ReactMethod
49
+ fun addListener(eventName: String?) {
50
+ }
51
+
52
+ @ReactMethod
53
+ fun removeListeners(count: Int?) {
54
+ }
55
+
56
+ @ReactMethod
57
+ fun initialize(promise: Promise) {
58
+ comnyxMessaging.initialize( { token ->
59
+ val params = Arguments.createMap()
60
+ params.putString("token", token)
61
+ sendEvent(reactApplicationContext, "TOKEN_INIT", params)
62
+ val activity = reactApplicationContext.currentActivity
63
+ if(activity?.intent !== null){
64
+ ComnyxModule.handleNewIntent(activity.intent)
65
+ }
66
+ promise.resolve(true)
67
+ },
68
+ { exception ->
69
+ promise.reject("TOKEN_FAILED", exception.message, exception)
70
+ }
71
+ )
72
+ }
73
+
74
+ @ReactMethod
75
+ fun checkOptIn(promise: Promise) {
76
+ Log.d(NAME, "Checking opt-in status")
77
+ try {
78
+ // Check system notification settings
79
+ val notificationManager = reactApplicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
80
+ val areNotificationsEnabled = notificationManager.areNotificationsEnabled()
81
+
82
+ // Check runtime permission for Android 13+
83
+ val permissionStatus = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
84
+ when (ContextCompat.checkSelfPermission(
85
+ reactApplicationContext,
86
+ Manifest.permission.POST_NOTIFICATIONS
87
+ )) {
88
+ PackageManager.PERMISSION_GRANTED -> "granted"
89
+ PackageManager.PERMISSION_DENIED -> {
90
+ // Check if user has selected "Don't ask again"
91
+ val activity = currentActivity
92
+ if (activity != null &&
93
+ !ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.POST_NOTIFICATIONS)) {
94
+ "blocked"
95
+ } else {
96
+ "denied"
97
+ }
98
+ }
99
+ else -> "denied"
100
+ }
101
+ } else {
102
+ // On Android 12 and below, check only system settings
103
+ if (areNotificationsEnabled) "granted" else "blocked"
104
+ }
105
+
106
+ Log.d(NAME, "Notification status: $permissionStatus")
107
+ promise.resolve(permissionStatus)
108
+ } catch (e: Exception) {
109
+ Log.e(NAME, "Error checking opt-in status: ${e.message}", e)
110
+ promise.reject("ERROR_CHECK_OPT_IN", e.message, e)
111
+ }
112
+ }
113
+
114
+ @ReactMethod
115
+ fun optIn(promise: Promise) {
116
+ Log.d(NAME, "Requesting opt-in permission")
117
+ try {
118
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
119
+ val activity = currentActivity
120
+ if (activity == null) {
121
+ throw Exception("Activity is not available")
122
+ }
123
+
124
+ if (ContextCompat.checkSelfPermission(
125
+ reactApplicationContext,
126
+ Manifest.permission.POST_NOTIFICATIONS
127
+ ) == PackageManager.PERMISSION_GRANTED
128
+ ) {
129
+ Log.d(NAME, "Permission already granted")
130
+ promise.resolve("granted")
131
+ return
132
+ }
133
+
134
+ pendingPromise = promise
135
+ ActivityCompat.requestPermissions(
136
+ activity,
137
+ arrayOf(Manifest.permission.POST_NOTIFICATIONS),
138
+ PERMISSION_REQUEST_CODE
139
+ )
140
+ } else {
141
+ // On Android 12 and below, check system settings
142
+ val notificationManager = reactApplicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
143
+ val areNotificationsEnabled = notificationManager.areNotificationsEnabled()
144
+ promise.resolve(if (areNotificationsEnabled) "granted" else "blocked")
145
+ }
146
+ } catch (e: Exception) {
147
+ Log.e(NAME, "Error requesting opt-in permission: ${e.message}", e)
148
+ promise.reject("ERROR_OPT_IN", e.message, e)
149
+ }
150
+ }
151
+
152
+ override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray): Boolean {
153
+ Log.d(NAME, "Permission result received - Request code: $requestCode")
154
+ if (requestCode == PERMISSION_REQUEST_CODE) {
155
+ val status = when {
156
+ grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED -> "granted"
157
+ currentActivity?.let {
158
+ !ActivityCompat.shouldShowRequestPermissionRationale(it, Manifest.permission.POST_NOTIFICATIONS)
159
+ } == true -> "blocked"
160
+ else -> "denied"
161
+ }
162
+ Log.d(NAME, "Permission status: $status")
163
+
164
+ pendingPromise?.resolve(status)
165
+ pendingPromise = null
166
+ return true
167
+ }
168
+ return false
169
+ }
170
+
171
+ fun onNotificationShown(params: WritableMap) {
172
+ sendEvent(reactApplicationContext, "NOTIFICATION_RECEIVED", params)
173
+ }
174
+
175
+ fun onNotificationClicked(params: WritableMap) {
176
+ sendEvent(reactApplicationContext, "NOTIFICATION_CLICKED", params)
177
+ }
178
+
179
+ @ReactMethod
180
+ fun linkToSettings(promise: Promise) {
181
+ try {
182
+ val intent = Intent()
183
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
184
+ intent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS
185
+ intent.putExtra(Settings.EXTRA_APP_PACKAGE, reactApplicationContext.packageName)
186
+ } else {
187
+ intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
188
+ intent.data = Uri.parse("package:" + reactApplicationContext.packageName)
189
+ }
190
+ intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
191
+ reactApplicationContext.startActivity(intent)
192
+ promise.resolve(true)
193
+ } catch (e: Exception) {
194
+ Log.e(NAME, "Failed to open settings: ${e.message}", e)
195
+ promise.reject("SETTINGS_ERROR", "Could not open notification settings", e)
196
+ }
197
+
198
+
18
199
  }
19
200
 
20
201
  companion object {
21
202
  const val NAME = "Comnyx"
203
+ var __self: ComnyxModule? = null
204
+
205
+ fun handleNewIntent(intent: android.content.Intent?) {
206
+ val type = intent?.getStringExtra("comnyx_type")
207
+ if(type != "notification_clicked" && type != "notification_shown") {
208
+ return
209
+ }
210
+ intent?.let {
211
+ val params = Arguments.createMap()
212
+ it.extras?.let { extras ->
213
+ for (key in extras.keySet()) {
214
+ val value = extras.get(key)
215
+ when (value) {
216
+ is String -> params.putString(key, value)
217
+ is Int -> params.putInt(key, value)
218
+ is Boolean -> params.putBoolean(key, value)
219
+ is Double -> params.putDouble(key, value)
220
+ }
221
+ }
222
+ }
223
+ if(type == "notification_clicked"){
224
+ __self?.onNotificationClicked(params)
225
+ } else {
226
+ __self?.onNotificationShown(params)
227
+ }
228
+ }
229
+ }
22
230
  }
23
231
  }
@@ -1,5 +1,4 @@
1
1
  package com.comnyx
2
-
3
2
  import com.facebook.react.BaseReactPackage
4
3
  import com.facebook.react.bridge.NativeModule
5
4
  import com.facebook.react.bridge.ReactApplicationContext
@@ -9,24 +8,29 @@ import java.util.HashMap
9
8
 
10
9
  class ComnyxPackage : BaseReactPackage() {
11
10
  override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
12
- return if (name == ComnyxModule.NAME) {
13
- ComnyxModule(reactContext)
14
- } else {
15
- null
11
+ return when (name) {
12
+ ComnyxModule.NAME -> ComnyxModule(reactContext)
13
+ else -> null
16
14
  }
17
15
  }
18
16
 
19
17
  override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
20
18
  return ReactModuleInfoProvider {
21
19
  val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
20
+
21
+ // Add ComnyxModule
22
22
  moduleInfos[ComnyxModule.NAME] = ReactModuleInfo(
23
23
  ComnyxModule.NAME,
24
24
  ComnyxModule.NAME,
25
25
  false, // canOverrideExistingModule
26
26
  false, // needsEagerInit
27
27
  false, // isCxxModule
28
- true // isTurboModule
28
+ false // isTurboModule
29
29
  )
30
+
31
+ // Add NotificationPermissionModule
32
+
33
+
30
34
  moduleInfos
31
35
  }
32
36
  }
@@ -0,0 +1,25 @@
1
+ package com.comnyx.messaging
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import android.util.Log
5
+
6
+ class ComnyxMessaging(reactApplicationContext: ReactApplicationContext) {
7
+ private val fcm : FCM?
8
+ private val reactApplicationContext : ReactApplicationContext
9
+
10
+ init {
11
+ this.reactApplicationContext = reactApplicationContext
12
+ this.fcm = FCM(reactApplicationContext)
13
+ }
14
+
15
+ public fun initialize(onSuccess: (token: String) -> Unit, onError: (exception: Exception) -> Unit) {
16
+ this.fcm!!.getToken(
17
+ onSuccess = { token ->
18
+ onSuccess(token)
19
+ },
20
+ onError = { exception ->
21
+ onError(exception)
22
+ }
23
+ )
24
+ }
25
+ }
@@ -0,0 +1,38 @@
1
+ package com.comnyx.messaging
2
+
3
+ import android.content.Context
4
+ import android.util.Log
5
+ import com.google.firebase.FirebaseApp
6
+ import com.google.firebase.messaging.FirebaseMessaging
7
+
8
+ class FCM(private val context: Context) {
9
+ companion object {
10
+ private const val TAG = "Comnyx"
11
+ }
12
+
13
+ init {
14
+ try {
15
+ if (FirebaseApp.getApps(context).isEmpty()) {
16
+ FirebaseApp.initializeApp(context)
17
+ Log.d(TAG, "Firebase initialized successfully")
18
+ }
19
+ } catch (e: Exception) {
20
+ Log.e(TAG, "Failed to initialize Firebase", e)
21
+ }
22
+ }
23
+
24
+ fun getToken(onSuccess: (String) -> Unit, onError: (Exception) -> Unit) {
25
+ FirebaseMessaging.getInstance().token
26
+ .addOnCompleteListener { task ->
27
+ if (task.isSuccessful) {
28
+ val token = task.result
29
+ Log.d(TAG, "FCM token: $token")
30
+ onSuccess(token)
31
+ } else {
32
+ val exception = task.exception ?: Exception("Unknown error occurred")
33
+ Log.e(TAG, "Failed to get FCM token", exception)
34
+ onError(exception)
35
+ }
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,45 @@
1
+ package com.comnyx.messaging
2
+
3
+ import android.util.Log
4
+ import com.comnyx.ComnyxModule
5
+ import com.google.firebase.messaging.FirebaseMessagingService
6
+ import com.google.firebase.messaging.RemoteMessage
7
+
8
+
9
+ class MyFirebaseMessagingService : FirebaseMessagingService() {
10
+
11
+ private lateinit var notificationsHelper: NotificationsHelper
12
+
13
+ override fun onCreate() {
14
+ super.onCreate()
15
+ notificationsHelper = NotificationsHelper(this)
16
+ }
17
+
18
+ override fun onMessageReceived(remoteMessage: RemoteMessage) {
19
+ //https://stackoverflow.com/a/40083727
20
+ super.onMessageReceived(remoteMessage)
21
+ Log.d("MyFirebaseMessagingService","onMessageReceived($remoteMessage)")
22
+ val title: String = remoteMessage.data["title"] ?: remoteMessage.notification?.title ?: ""
23
+ val body: String = remoteMessage.data["body"] ?: remoteMessage.notification?.body ?: ""
24
+
25
+ notificationsHelper.showNotification(title, body, remoteMessage.data)
26
+ }
27
+
28
+
29
+
30
+
31
+ override fun onNewToken(token: String) {
32
+ sendRegistrationToServer(token)
33
+ }
34
+
35
+
36
+ private fun sendRegistrationToServer(token: String) {
37
+ //TODO: send token to server
38
+ Log.d("MyFirebaseMessagingService","sendRegistrationTokenToServer($token)")
39
+ }
40
+
41
+
42
+ companion object {
43
+
44
+ }
45
+ }
@@ -0,0 +1,99 @@
1
+ package com.comnyx.messaging
2
+
3
+ import android.app.NotificationChannel
4
+ import android.app.NotificationManager
5
+ import android.app.PendingIntent
6
+ import android.content.Context
7
+ import android.content.Intent
8
+ import android.graphics.Color
9
+ import android.os.Build
10
+ import android.util.Log
11
+ import androidx.core.app.NotificationCompat
12
+ import com.comnyx.ComnyxModule
13
+ import com.facebook.react.bridge.Arguments
14
+ import com.facebook.react.bridge.WritableMap
15
+
16
+ class NotificationsHelper(private val context: Context) {
17
+
18
+ companion object {
19
+ private const val CHANNEL_ID = "COMNYX_NOTIFICATION_CHANNEL"
20
+ private const val NOTIFICATION_ID = 1001
21
+ private const val TAG = "ComnyxNotifications"
22
+ }
23
+
24
+ init {
25
+ Log.d(TAG, "Initializing NotificationsHelper")
26
+ createNotificationChannel()
27
+ }
28
+
29
+ private fun createNotificationChannel() {
30
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
31
+ Log.d(TAG, "Creating notification channel for Android O and above")
32
+ val name = "Standard Notifications"
33
+ val description = "Regular notifications channel"
34
+ val importance = NotificationManager.IMPORTANCE_DEFAULT
35
+ val channel = NotificationChannel(CHANNEL_ID, name, importance)
36
+ channel.description = description
37
+
38
+ val notificationManager = context.getSystemService(NotificationManager::class.java)
39
+ channel.apply {
40
+ lightColor = Color.BLUE
41
+ enableLights(true)
42
+ setShowBadge(true)
43
+ enableVibration(true)
44
+ }
45
+ notificationManager.createNotificationChannel(channel)
46
+ Log.d(TAG, "Notification channel created successfully")
47
+ } else {
48
+ Log.d(TAG, "Skipping notification channel creation - running on Android N or below")
49
+ }
50
+ }
51
+
52
+ fun showNotification(title: String, message: String, data: Map<String, String>? = null) {
53
+ Log.d(TAG, "Showing notification - Title: $title, Message: $message")
54
+
55
+ // Create pending intent for notification click
56
+ val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
57
+ ?: Intent().setPackage(context.packageName)
58
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
59
+
60
+ // Add all data as extras
61
+ data?.let {
62
+ Log.d(TAG, "Adding extra data to notification: $it")
63
+ }
64
+ data?.forEach { (key, value) ->
65
+ intent.putExtra(key, value)
66
+ }
67
+ intent.putExtra("comnyx_type", "notification_clicked")
68
+ intent.putExtra("notification_title", title)
69
+ intent.putExtra("notification_message", message)
70
+
71
+ try {
72
+ val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
73
+ val builder = NotificationCompat.Builder(context, CHANNEL_ID)
74
+ .setContentTitle(title)
75
+ .setContentText(message)
76
+ .setSmallIcon(android.R.drawable.ic_dialog_info)
77
+ .setPriority(NotificationCompat.PRIORITY_DEFAULT)
78
+ .setNumber(100)
79
+ .setAutoCancel(true)
80
+ .setContentIntent(pendingIntent)
81
+
82
+ val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
83
+ notificationManager.notify(NOTIFICATION_ID, builder.build())
84
+ Log.d(TAG, "Notification displayed successfully")
85
+
86
+ val writableMap: WritableMap = Arguments.createMap()
87
+ writableMap.putString("comnyx_type", "notification_shown")
88
+ writableMap.putString("notification_title", title)
89
+ writableMap.putString("notification_message", message)
90
+ data?.forEach { (key, value) ->
91
+ writableMap.putString(key, value)
92
+ }
93
+ ComnyxModule.__self?.onNotificationShown(writableMap)
94
+ Log.d(TAG, "Notification event sent to JS")
95
+ } catch (e: Exception) {
96
+ Log.e(TAG, "Error showing notification: ${e.message}", e)
97
+ }
98
+ }
99
+ }
@@ -0,0 +1,74 @@
1
+ //
2
+ // APN.swift
3
+ // Pods
4
+ //
5
+ // Created by Hasbi Sefa Demir on 15.05.2025.
6
+ //
7
+
8
+ import Foundation
9
+ import UserNotifications
10
+ import UIKit
11
+ import ObjectiveC.runtime
12
+
13
+ class APNService {
14
+ public var called = false
15
+ public var token: String?
16
+
17
+ private var tokenCompletion: ((String, String?) -> Void)?
18
+
19
+ init() {
20
+ self.token = UserDefaults.standard.string(forKey: "APN_TOKEN")
21
+ }
22
+
23
+ deinit {
24
+ NotificationCenter.default.removeObserver(self)
25
+ }
26
+
27
+ func setAPNTokenListener(completion: @escaping (String, String?) -> Void) {
28
+ self.tokenCompletion = completion
29
+ if(self.token != nil){
30
+ completion("cache", self.token!)
31
+ }
32
+
33
+ UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
34
+ guard granted else {
35
+ return
36
+ }
37
+
38
+ DispatchQueue.main.async {
39
+ UIApplication.shared.registerForRemoteNotifications()
40
+ // Register for token notifications
41
+ NotificationCenter.default.addObserver(
42
+ self,
43
+ selector: #selector(self.didRegisterForRemoteNotifications),
44
+ name: NSNotification.Name("RCTRemoteNotificationRegistered"),
45
+ object: nil
46
+ )
47
+
48
+ NotificationCenter.default.addObserver(
49
+ self,
50
+ selector: #selector(self.didFailToRegisterForRemoteNotifications),
51
+ name: NSNotification.Name("RCTRemoteNotificationRegistrationFailed"),
52
+ object: nil
53
+ )
54
+ }
55
+ }
56
+ }
57
+
58
+ @objc private func didRegisterForRemoteNotifications(notification: Notification) {
59
+ guard let deviceToken = notification.userInfo?["deviceToken"] as? String else {
60
+ return
61
+ }
62
+ if(self.token != deviceToken){
63
+ UserDefaults.standard.set(deviceToken, forKey: "APN_TOKEN")
64
+ self.token = deviceToken
65
+ tokenCompletion?("received", deviceToken)
66
+ }
67
+ }
68
+
69
+ @objc private func didFailToRegisterForRemoteNotifications(notification: Notification) {
70
+ tokenCompletion?("failed", nil)
71
+ }
72
+
73
+ }
74
+
@@ -0,0 +1,17 @@
1
+ //
2
+ // header.swift
3
+ // Pods
4
+ //
5
+ // Created by Hasbi Sefa Demir on 17.05.2025.
6
+ //
7
+
8
+
9
+ #import <React/RCTViewManager.h>
10
+ #import <React/RCTBundleURLProvider.h>
11
+ #import <React/RCTRootView.h>
12
+ #import <React/RCTComponent.h>
13
+ #import <React/RCTBridgeModule.h>
14
+ #import <React/RCTViewManager.h>
15
+ #import <React/RCTDevLoadingView.h>
16
+ #import "React/RCTEventEmitter.h"
17
+ #import <React/RCTUIManager.h>
package/ios/Comnyx.m ADDED
@@ -0,0 +1,18 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTEventEmitter.h>
3
+
4
+ @interface RCT_EXTERN_MODULE(Comnyx, RCTEventEmitter)
5
+
6
+ RCT_EXTERN_METHOD(checkOptIn:(RCTPromiseResolveBlock)resolve
7
+ reject:(RCTPromiseRejectBlock)reject)
8
+
9
+ RCT_EXTERN_METHOD(optIn:(RCTPromiseResolveBlock)resolve
10
+ reject:(RCTPromiseRejectBlock)reject)
11
+
12
+ RCT_EXTERN_METHOD(initialize:(RCTPromiseResolveBlock)resolve
13
+ rejecter:(RCTPromiseRejectBlock)reject)
14
+
15
+ RCT_EXTERN_METHOD(linkToSettings:(RCTPromiseResolveBlock)resolve
16
+ reject:(RCTPromiseRejectBlock)reject)
17
+
18
+ @end