@developer_tribe/react-native-comnyx 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Comnyx.podspec +1 -1
- package/README.md +192 -16
- package/android/build.gradle +13 -1
- package/android/generated/RCTAppDependencyProvider.h +25 -0
- package/android/generated/RCTAppDependencyProvider.mm +55 -0
- package/android/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/android/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/android/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/android/generated/RCTThirdPartyComponentsProvider.mm +23 -0
- package/android/generated/ReactAppDependencyProvider.podspec +34 -0
- package/android/generated/jni/RNComnyxSpec-generated.cpp +1 -11
- package/android/generated/jni/RNComnyxSpec.h +0 -7
- package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI-generated.cpp +0 -11
- package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI.h +0 -52
- package/android/src/main/AndroidManifestNew.xml +10 -0
- package/android/src/main/java/com/comnyx/ComnyxModule.kt +107 -5
- package/android/src/main/java/com/comnyx/ComnyxPackage.kt +10 -6
- package/android/src/main/java/com/comnyx/src/messaging/ComnyxMessaging.kt +45 -0
- package/android/src/main/java/com/comnyx/src/messaging/firebase/FCM.kt +38 -0
- package/android/src/main/java/com/comnyx/src/messaging/firebase/FirebaseMessagingService.kt +45 -0
- package/android/src/main/java/com/comnyx/src/messaging/notifications/NotificationsService.kt +82 -0
- package/android/src/main/java/com/comnyx/src/messaging/permissions/Permissions.kt +64 -0
- package/ios/APNService.swift +74 -0
- package/ios/Comnyx-Bridging-Header.h +17 -0
- package/ios/Comnyx.m +15 -0
- package/ios/Comnyx.swift +77 -0
- package/ios/ComnyxMessaging.swift +84 -0
- package/ios/PushService.swift +7 -0
- package/lib/commonjs/NativeComnyx.js +9 -0
- package/lib/commonjs/NativeComnyx.js.map +1 -0
- package/lib/commonjs/api/api.js +14 -3
- package/lib/commonjs/api/api.js.map +1 -1
- package/lib/commonjs/api/customers.js +3 -8
- package/lib/commonjs/api/customers.js.map +1 -1
- package/lib/commonjs/api/index.js +1 -1
- package/lib/commonjs/components/AppText.js +1 -1
- package/lib/commonjs/components/AppText.js.map +1 -1
- package/lib/commonjs/components/ChatList.js +1 -1
- package/lib/commonjs/components/ChatList.js.map +1 -1
- package/lib/commonjs/components/CustomerForm.js +2 -4
- package/lib/commonjs/components/CustomerForm.js.map +1 -1
- package/lib/commonjs/components/MessageInput.js +1 -1
- package/lib/commonjs/components/MessageInput.js.map +1 -1
- package/lib/commonjs/constants/viewabilityConfig.js.map +1 -0
- package/lib/commonjs/hooks/isRtl.js +1 -1
- package/lib/commonjs/hooks/useLocalize.js +1 -1
- package/lib/commonjs/hooks/useLocalize.js.map +1 -1
- package/lib/commonjs/hooks/usePolling.js +1 -1
- package/lib/commonjs/hooks/usePolling.js.map +1 -1
- package/lib/commonjs/hooks/useTheme.js +1 -1
- package/lib/commonjs/hooks/useTheme.js.map +1 -1
- package/lib/commonjs/index.js +9 -16
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/notifications/index.js +21 -0
- package/lib/commonjs/notifications/index.js.map +1 -0
- package/lib/commonjs/{Accumulator.js → register/Accumulator.js} +8 -1
- package/lib/commonjs/register/Accumulator.js.map +1 -0
- package/lib/commonjs/{collectData.js → register/collectData.js} +2 -0
- package/lib/commonjs/register/collectData.js.map +1 -0
- package/lib/commonjs/register/index.js +17 -0
- package/lib/commonjs/register/index.js.map +1 -0
- package/lib/commonjs/register/init.js +14 -0
- package/lib/commonjs/register/init.js.map +1 -0
- package/lib/commonjs/register/login.js +24 -0
- package/lib/commonjs/register/login.js.map +1 -0
- package/lib/commonjs/register/logout.js +20 -0
- package/lib/commonjs/register/logout.js.map +1 -0
- package/lib/commonjs/{store.js → store/store.js} +3 -2
- package/lib/commonjs/store/store.js.map +1 -0
- package/lib/commonjs/{App.js → support/ComnyxSupport.js} +39 -14
- package/lib/commonjs/support/ComnyxSupport.js.map +1 -0
- package/lib/commonjs/support/index.js +13 -0
- package/lib/commonjs/support/index.js.map +1 -0
- package/lib/commonjs/utils/scalingUtils.js +1 -1
- package/lib/module/NativeComnyx.js +5 -0
- package/lib/module/NativeComnyx.js.map +1 -0
- package/lib/module/api/api.js +11 -3
- package/lib/module/api/api.js.map +1 -1
- package/lib/module/api/customers.js +3 -7
- package/lib/module/api/customers.js.map +1 -1
- package/lib/module/api/index.js +1 -1
- package/lib/module/api/index.js.map +1 -1
- package/lib/module/components/AppText.js +1 -1
- package/lib/module/components/AppText.js.map +1 -1
- package/lib/module/components/ChatList.js +1 -1
- package/lib/module/components/ChatList.js.map +1 -1
- package/lib/module/components/CustomerForm.js +2 -4
- package/lib/module/components/CustomerForm.js.map +1 -1
- package/lib/module/components/MessageInput.js +1 -1
- package/lib/module/components/MessageInput.js.map +1 -1
- package/lib/module/constants/viewabilityConfig.js.map +1 -0
- package/lib/module/hooks/isRtl.js +1 -1
- package/lib/module/hooks/isRtl.js.map +1 -1
- package/lib/module/hooks/useLocalize.js +1 -1
- package/lib/module/hooks/useLocalize.js.map +1 -1
- package/lib/module/hooks/usePolling.js +1 -1
- package/lib/module/hooks/usePolling.js.map +1 -1
- package/lib/module/hooks/useTheme.js +1 -1
- package/lib/module/hooks/useTheme.js.map +1 -1
- package/lib/module/index.js +8 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/notifications/index.js +19 -0
- package/lib/module/notifications/index.js.map +1 -0
- package/lib/module/{Accumulator.js → register/Accumulator.js} +7 -1
- package/lib/module/register/Accumulator.js.map +1 -0
- package/lib/module/{collectData.js → register/collectData.js} +2 -0
- package/lib/module/register/collectData.js.map +1 -0
- package/lib/module/register/index.js +13 -0
- package/lib/module/register/index.js.map +1 -0
- package/lib/module/register/init.js +10 -0
- package/lib/module/register/init.js.map +1 -0
- package/lib/module/register/login.js +20 -0
- package/lib/module/register/login.js.map +1 -0
- package/lib/module/register/logout.js +16 -0
- package/lib/module/register/logout.js.map +1 -0
- package/lib/module/{store.js → store/store.js} +2 -2
- package/lib/module/store/store.js.map +1 -0
- package/lib/module/{App.js → support/ComnyxSupport.js} +40 -15
- package/lib/module/support/ComnyxSupport.js.map +1 -0
- package/lib/module/support/index.js +4 -0
- package/lib/module/support/index.js.map +1 -0
- package/lib/module/utils/scalingUtils.js +1 -1
- package/lib/module/utils/scalingUtils.js.map +1 -1
- package/lib/typescript/jest.config.d.ts +4 -0
- package/lib/typescript/jest.config.d.ts.map +1 -0
- package/lib/typescript/setup-jest.d.ts +1 -0
- package/lib/typescript/setup-jest.d.ts.map +1 -0
- package/lib/typescript/src/NativeComnyx.d.ts +7 -0
- package/lib/typescript/src/NativeComnyx.d.ts.map +1 -0
- package/lib/typescript/src/api/api.d.ts +7 -0
- package/lib/typescript/src/api/api.d.ts.map +1 -0
- package/lib/typescript/src/api/conversations.d.ts.map +1 -0
- package/lib/typescript/src/api/customers.d.ts +5 -0
- package/lib/typescript/src/api/customers.d.ts.map +1 -0
- package/lib/typescript/{commonjs/src → src}/api/index.d.ts +1 -1
- package/lib/typescript/src/api/index.d.ts.map +1 -0
- package/lib/typescript/src/api/messages.d.ts.map +1 -0
- package/lib/typescript/src/components/AppText.d.ts.map +1 -0
- package/lib/typescript/src/components/ChatList.d.ts.map +1 -0
- package/lib/typescript/src/components/CustomAlert.d.ts.map +1 -0
- package/lib/typescript/src/components/CustomerForm.d.ts.map +1 -0
- package/lib/typescript/src/components/EmptyList.d.ts.map +1 -0
- package/lib/typescript/src/components/InitFailed.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageInput.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageItem.d.ts.map +1 -0
- package/lib/typescript/src/components/ScaledSheet.d.ts.map +1 -0
- package/lib/typescript/src/constants/activeOpacity.d.ts.map +1 -0
- package/lib/typescript/src/constants/countries.d.ts.map +1 -0
- package/lib/typescript/src/constants/rtl.d.ts.map +1 -0
- package/lib/typescript/src/constants/translations.d.ts.map +1 -0
- package/lib/typescript/src/constants/viewabilityConfig.d.ts.map +1 -0
- package/lib/typescript/src/data/fake/conversations.d.ts.map +1 -0
- package/lib/typescript/src/data/fake/customers.d.ts.map +1 -0
- package/lib/typescript/src/data/fake/messages.d.ts.map +1 -0
- package/lib/typescript/src/hooks/isRtl.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useLocalize.d.ts.map +1 -0
- package/lib/typescript/src/hooks/usePolling.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useTheme.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useThemeColors.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/notifications/index.d.ts +21 -0
- package/lib/typescript/src/notifications/index.d.ts.map +1 -0
- package/lib/typescript/{commonjs/src → src/register}/Accumulator.d.ts +4 -3
- package/lib/typescript/src/register/Accumulator.d.ts.map +1 -0
- package/lib/typescript/src/register/collectData.d.ts.map +1 -0
- package/lib/typescript/src/register/index.d.ts +11 -0
- package/lib/typescript/src/register/index.d.ts.map +1 -0
- package/lib/typescript/src/register/init.d.ts +6 -0
- package/lib/typescript/src/register/init.d.ts.map +1 -0
- package/lib/typescript/src/register/login.d.ts +6 -0
- package/lib/typescript/src/register/login.d.ts.map +1 -0
- package/lib/typescript/src/register/logout.d.ts +2 -0
- package/lib/typescript/src/register/logout.d.ts.map +1 -0
- package/lib/typescript/{module/src → src/store}/store.d.ts +6 -4
- package/lib/typescript/src/store/store.d.ts.map +1 -0
- package/lib/typescript/src/support/ComnyxSupport.d.ts +12 -0
- package/lib/typescript/src/support/ComnyxSupport.d.ts.map +1 -0
- package/lib/typescript/src/support/index.d.ts +2 -0
- package/lib/typescript/src/support/index.d.ts.map +1 -0
- package/lib/typescript/src/types/ApiOptions.d.ts.map +1 -0
- package/lib/typescript/src/types/Conversation.d.ts.map +1 -0
- package/lib/typescript/src/types/Customer.d.ts.map +1 -0
- package/lib/typescript/src/types/GlobalTheme.d.ts.map +1 -0
- package/lib/typescript/src/types/Language.d.ts.map +1 -0
- package/lib/typescript/src/types/LocalizationKeys.d.ts.map +1 -0
- package/lib/typescript/src/types/MessageResponse.d.ts.map +1 -0
- package/lib/typescript/src/types/Theme.d.ts.map +1 -0
- package/lib/typescript/src/utils/date.d.ts.map +1 -0
- package/lib/typescript/src/utils/deepMap.d.ts.map +1 -0
- package/lib/typescript/src/utils/formatDate.d.ts.map +1 -0
- package/lib/typescript/src/utils/scalingUtils.d.ts.map +1 -0
- package/package.json +13 -27
- package/src/NativeComnyx.ts +6 -5
- package/src/api/api.ts +14 -3
- package/src/api/customers.ts +3 -8
- package/src/api/index.ts +1 -1
- package/src/components/AppText.tsx +1 -1
- package/src/components/ChatList.tsx +1 -1
- package/src/components/CustomerForm.tsx +2 -3
- package/src/components/MessageInput.tsx +1 -1
- package/src/hooks/isRtl.ts +1 -1
- package/src/hooks/useLocalize.ts +1 -1
- package/src/hooks/usePolling.ts +1 -1
- package/src/hooks/useTheme.ts +1 -1
- package/src/index.ts +8 -0
- package/src/notifications/index.ts +49 -0
- package/src/{Accumulator.ts → register/Accumulator.ts} +10 -2
- package/src/{collectData.ts → register/collectData.ts} +1 -0
- package/src/register/index.ts +11 -0
- package/src/register/init.ts +16 -0
- package/src/register/login.ts +23 -0
- package/src/register/logout.ts +14 -0
- package/src/{store.ts → store/store.ts} +7 -7
- package/src/{App.tsx → support/ComnyxSupport.tsx} +41 -14
- package/src/support/index.ts +1 -0
- package/src/utils/scalingUtils.ts +1 -1
- package/android/generated/java/com/comnyx/NativeComnyxSpec.java +0 -37
- package/ios/Comnyx.h +0 -6
- package/ios/Comnyx.mm +0 -18
- package/ios/generated/RNComnyxSpec/RNComnyxSpec-generated.mm +0 -39
- package/ios/generated/RNComnyxSpec/RNComnyxSpec.h +0 -63
- package/ios/generated/RNComnyxSpecJSI-generated.cpp +0 -28
- package/ios/generated/RNComnyxSpecJSI.h +0 -71
- package/lib/commonjs/Accumulator.js.map +0 -1
- package/lib/commonjs/App.js.map +0 -1
- package/lib/commonjs/NativeComnyx.ts +0 -8
- package/lib/commonjs/__dev__.js +0 -29
- package/lib/commonjs/__dev__.js.map +0 -1
- package/lib/commonjs/collectData.js.map +0 -1
- package/lib/commonjs/components/SizeMatter.js +0 -27
- package/lib/commonjs/components/SizeMatter.js.map +0 -1
- package/lib/commonjs/package.json +0 -1
- package/lib/commonjs/register.js +0 -26
- package/lib/commonjs/register.js.map +0 -1
- package/lib/commonjs/store.js.map +0 -1
- package/lib/commonjs/viewabilityConfig.js.map +0 -1
- package/lib/module/Accumulator.js.map +0 -1
- package/lib/module/App.js.map +0 -1
- package/lib/module/NativeComnyx.ts +0 -8
- package/lib/module/__dev__.js +0 -29
- package/lib/module/__dev__.js.map +0 -1
- package/lib/module/collectData.js.map +0 -1
- package/lib/module/components/SizeMatter.js +0 -23
- package/lib/module/components/SizeMatter.js.map +0 -1
- package/lib/module/package.json +0 -1
- package/lib/module/register.js +0 -22
- package/lib/module/register.js.map +0 -1
- package/lib/module/store.js.map +0 -1
- package/lib/module/viewabilityConfig.js.map +0 -1
- package/lib/typescript/commonjs/package.json +0 -1
- package/lib/typescript/commonjs/src/Accumulator.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/App.d.ts +0 -12
- package/lib/typescript/commonjs/src/App.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/NativeComnyx.d.ts +0 -7
- package/lib/typescript/commonjs/src/NativeComnyx.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/__dev__.d.ts +0 -2
- package/lib/typescript/commonjs/src/__dev__.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/api/api.d.ts +0 -4
- package/lib/typescript/commonjs/src/api/api.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/api/conversations.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/api/customers.d.ts +0 -6
- package/lib/typescript/commonjs/src/api/customers.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/api/index.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/api/messages.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/collectData.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/AppText.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/ChatList.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/CustomAlert.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/CustomerForm.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/EmptyList.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/InitFailed.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/MessageInput.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/MessageItem.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/ScaledSheet.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/SizeMatter.d.ts +0 -7
- package/lib/typescript/commonjs/src/components/SizeMatter.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/constants/activeOpacity.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/constants/countries.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/constants/rtl.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/constants/translations.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/data/fake/conversations.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/data/fake/customers.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/data/fake/messages.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/hooks/isRtl.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/hooks/useLocalize.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/hooks/usePolling.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/hooks/useTheme.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/hooks/useThemeColors.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/index.d.ts +0 -7
- package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/register.d.ts +0 -5
- package/lib/typescript/commonjs/src/register.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/store.d.ts +0 -40
- package/lib/typescript/commonjs/src/store.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/ApiOptions.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/Conversation.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/Customer.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/GlobalTheme.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/Language.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/LocalizationKeys.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/MessageResponse.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/Theme.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/utils/date.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/utils/deepMap.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/utils/formatDate.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/utils/scalingUtils.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/viewabilityConfig.d.ts.map +0 -1
- package/lib/typescript/module/package.json +0 -1
- package/lib/typescript/module/src/Accumulator.d.ts +0 -18
- package/lib/typescript/module/src/Accumulator.d.ts.map +0 -1
- package/lib/typescript/module/src/App.d.ts +0 -12
- package/lib/typescript/module/src/App.d.ts.map +0 -1
- package/lib/typescript/module/src/NativeComnyx.d.ts +0 -7
- package/lib/typescript/module/src/NativeComnyx.d.ts.map +0 -1
- package/lib/typescript/module/src/__dev__.d.ts +0 -2
- package/lib/typescript/module/src/__dev__.d.ts.map +0 -1
- package/lib/typescript/module/src/api/api.d.ts +0 -4
- package/lib/typescript/module/src/api/api.d.ts.map +0 -1
- package/lib/typescript/module/src/api/conversations.d.ts +0 -7
- package/lib/typescript/module/src/api/conversations.d.ts.map +0 -1
- package/lib/typescript/module/src/api/customers.d.ts +0 -6
- package/lib/typescript/module/src/api/customers.d.ts.map +0 -1
- package/lib/typescript/module/src/api/index.d.ts +0 -4
- package/lib/typescript/module/src/api/index.d.ts.map +0 -1
- package/lib/typescript/module/src/api/messages.d.ts +0 -4
- package/lib/typescript/module/src/api/messages.d.ts.map +0 -1
- package/lib/typescript/module/src/collectData.d.ts +0 -3
- package/lib/typescript/module/src/collectData.d.ts.map +0 -1
- package/lib/typescript/module/src/components/AppText.d.ts +0 -14
- package/lib/typescript/module/src/components/AppText.d.ts.map +0 -1
- package/lib/typescript/module/src/components/ChatList.d.ts +0 -4
- package/lib/typescript/module/src/components/ChatList.d.ts.map +0 -1
- package/lib/typescript/module/src/components/CustomAlert.d.ts +0 -15
- package/lib/typescript/module/src/components/CustomAlert.d.ts.map +0 -1
- package/lib/typescript/module/src/components/CustomerForm.d.ts +0 -4
- package/lib/typescript/module/src/components/CustomerForm.d.ts.map +0 -1
- package/lib/typescript/module/src/components/EmptyList.d.ts +0 -2
- package/lib/typescript/module/src/components/EmptyList.d.ts.map +0 -1
- package/lib/typescript/module/src/components/InitFailed.d.ts +0 -6
- package/lib/typescript/module/src/components/InitFailed.d.ts.map +0 -1
- package/lib/typescript/module/src/components/MessageInput.d.ts +0 -5
- package/lib/typescript/module/src/components/MessageInput.d.ts.map +0 -1
- package/lib/typescript/module/src/components/MessageItem.d.ts +0 -6
- package/lib/typescript/module/src/components/MessageItem.d.ts.map +0 -1
- package/lib/typescript/module/src/components/ScaledSheet.d.ts +0 -2
- package/lib/typescript/module/src/components/ScaledSheet.d.ts.map +0 -1
- package/lib/typescript/module/src/components/SizeMatter.d.ts +0 -7
- package/lib/typescript/module/src/components/SizeMatter.d.ts.map +0 -1
- package/lib/typescript/module/src/constants/activeOpacity.d.ts +0 -2
- package/lib/typescript/module/src/constants/activeOpacity.d.ts.map +0 -1
- package/lib/typescript/module/src/constants/countries.d.ts +0 -7
- package/lib/typescript/module/src/constants/countries.d.ts.map +0 -1
- package/lib/typescript/module/src/constants/rtl.d.ts +0 -2
- package/lib/typescript/module/src/constants/rtl.d.ts.map +0 -1
- package/lib/typescript/module/src/constants/translations.d.ts +0 -4
- package/lib/typescript/module/src/constants/translations.d.ts.map +0 -1
- package/lib/typescript/module/src/data/fake/conversations.d.ts +0 -5
- package/lib/typescript/module/src/data/fake/conversations.d.ts.map +0 -1
- package/lib/typescript/module/src/data/fake/customers.d.ts +0 -3
- package/lib/typescript/module/src/data/fake/customers.d.ts.map +0 -1
- package/lib/typescript/module/src/data/fake/messages.d.ts +0 -3
- package/lib/typescript/module/src/data/fake/messages.d.ts.map +0 -1
- package/lib/typescript/module/src/hooks/isRtl.d.ts +0 -2
- package/lib/typescript/module/src/hooks/isRtl.d.ts.map +0 -1
- package/lib/typescript/module/src/hooks/useLocalize.d.ts +0 -3
- package/lib/typescript/module/src/hooks/useLocalize.d.ts.map +0 -1
- package/lib/typescript/module/src/hooks/usePolling.d.ts +0 -2
- package/lib/typescript/module/src/hooks/usePolling.d.ts.map +0 -1
- package/lib/typescript/module/src/hooks/useTheme.d.ts +0 -3
- package/lib/typescript/module/src/hooks/useTheme.d.ts.map +0 -1
- package/lib/typescript/module/src/hooks/useThemeColors.d.ts +0 -3
- package/lib/typescript/module/src/hooks/useThemeColors.d.ts.map +0 -1
- package/lib/typescript/module/src/index.d.ts +0 -7
- package/lib/typescript/module/src/index.d.ts.map +0 -1
- package/lib/typescript/module/src/register.d.ts +0 -5
- package/lib/typescript/module/src/register.d.ts.map +0 -1
- package/lib/typescript/module/src/store.d.ts.map +0 -1
- package/lib/typescript/module/src/types/ApiOptions.d.ts +0 -4
- package/lib/typescript/module/src/types/ApiOptions.d.ts.map +0 -1
- package/lib/typescript/module/src/types/Conversation.d.ts +0 -33
- package/lib/typescript/module/src/types/Conversation.d.ts.map +0 -1
- package/lib/typescript/module/src/types/Customer.d.ts +0 -39
- package/lib/typescript/module/src/types/Customer.d.ts.map +0 -1
- package/lib/typescript/module/src/types/GlobalTheme.d.ts +0 -6
- package/lib/typescript/module/src/types/GlobalTheme.d.ts.map +0 -1
- package/lib/typescript/module/src/types/Language.d.ts +0 -2
- package/lib/typescript/module/src/types/Language.d.ts.map +0 -1
- package/lib/typescript/module/src/types/LocalizationKeys.d.ts +0 -43
- package/lib/typescript/module/src/types/LocalizationKeys.d.ts.map +0 -1
- package/lib/typescript/module/src/types/MessageResponse.d.ts +0 -61
- package/lib/typescript/module/src/types/MessageResponse.d.ts.map +0 -1
- package/lib/typescript/module/src/types/Theme.d.ts +0 -28
- package/lib/typescript/module/src/types/Theme.d.ts.map +0 -1
- package/lib/typescript/module/src/utils/date.d.ts +0 -7
- package/lib/typescript/module/src/utils/date.d.ts.map +0 -1
- package/lib/typescript/module/src/utils/deepMap.d.ts +0 -7
- package/lib/typescript/module/src/utils/deepMap.d.ts.map +0 -1
- package/lib/typescript/module/src/utils/formatDate.d.ts +0 -2
- package/lib/typescript/module/src/utils/formatDate.d.ts.map +0 -1
- package/lib/typescript/module/src/utils/scalingUtils.d.ts +0 -10
- package/lib/typescript/module/src/utils/scalingUtils.d.ts.map +0 -1
- package/lib/typescript/module/src/viewabilityConfig.d.ts +0 -5
- package/lib/typescript/module/src/viewabilityConfig.d.ts.map +0 -1
- package/src/__dev__.ts +0 -22
- package/src/components/SizeMatter.tsx +0 -22
- package/src/index.tsx +0 -9
- package/src/register.ts +0 -29
- /package/lib/commonjs/{viewabilityConfig.js → constants/viewabilityConfig.js} +0 -0
- /package/lib/module/{viewabilityConfig.js → constants/viewabilityConfig.js} +0 -0
- /package/lib/typescript/{commonjs/src → src}/api/conversations.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/api/messages.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/AppText.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/ChatList.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/CustomAlert.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/CustomerForm.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/EmptyList.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/InitFailed.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/MessageInput.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/MessageItem.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/ScaledSheet.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/constants/activeOpacity.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/constants/countries.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/constants/rtl.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/constants/translations.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src/constants}/viewabilityConfig.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/data/fake/conversations.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/data/fake/customers.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/data/fake/messages.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/hooks/isRtl.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/hooks/useLocalize.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/hooks/usePolling.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/hooks/useTheme.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/hooks/useThemeColors.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src/register}/collectData.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/types/ApiOptions.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/types/Conversation.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/types/Customer.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/types/GlobalTheme.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/types/Language.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/types/LocalizationKeys.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/types/MessageResponse.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/types/Theme.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/utils/date.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/utils/deepMap.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/utils/formatDate.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/utils/scalingUtils.d.ts +0 -0
- /package/src/{viewabilityConfig.ts → constants/viewabilityConfig.ts} +0 -0
|
@@ -1,23 +1,125 @@
|
|
|
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
|
|
5
13
|
|
|
6
14
|
@ReactModule(name = ComnyxModule.NAME)
|
|
7
15
|
class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
8
|
-
|
|
16
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
17
|
+
private val comnyxMessaging : ComnyxMessaging
|
|
18
|
+
|
|
19
|
+
init {
|
|
20
|
+
comnyxMessaging = ComnyxMessaging(reactContext)
|
|
21
|
+
__self = this
|
|
22
|
+
}
|
|
9
23
|
|
|
10
24
|
override fun getName(): String {
|
|
11
25
|
return NAME
|
|
12
26
|
}
|
|
13
27
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
private fun sendEvent(reactContext: ReactContext, eventName: String, params: Any?) {
|
|
29
|
+
reactContext
|
|
30
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
31
|
+
.emit(eventName, params)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@ReactMethod
|
|
35
|
+
fun addListener(eventName: String?) {
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@ReactMethod
|
|
39
|
+
fun removeListeners(count: Int?) {
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@ReactMethod
|
|
43
|
+
fun initialize(promise: Promise) {
|
|
44
|
+
comnyxMessaging.initialize( { token ->
|
|
45
|
+
val params = Arguments.createMap()
|
|
46
|
+
params.putString("token", token)
|
|
47
|
+
sendEvent(reactApplicationContext, "TOKEN_INIT", params)
|
|
48
|
+
val activity = reactApplicationContext.currentActivity
|
|
49
|
+
if(activity?.intent !== null){
|
|
50
|
+
ComnyxModule.handleNewIntent(activity.intent)
|
|
51
|
+
}
|
|
52
|
+
promise.resolve(true)
|
|
53
|
+
},
|
|
54
|
+
{ exception ->
|
|
55
|
+
promise.reject("TOKEN_FAILED", exception.message, exception)
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@ReactMethod
|
|
61
|
+
fun checkOptIn(promise: Promise) {
|
|
62
|
+
this.comnyxMessaging.checkOptIn(
|
|
63
|
+
{ isGranted ->
|
|
64
|
+
promise.resolve(isGranted)
|
|
65
|
+
},
|
|
66
|
+
{ exception ->
|
|
67
|
+
promise.reject("ERROR_CHECK_OPT_IN", exception.message, exception)
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@ReactMethod
|
|
73
|
+
fun optIn(promise: Promise) {
|
|
74
|
+
comnyxMessaging.optIn(
|
|
75
|
+
{ isGranted ->
|
|
76
|
+
promise.resolve(isGranted)
|
|
77
|
+
},
|
|
78
|
+
{ exception ->
|
|
79
|
+
promise.reject("ERROR_OPT_IN", exception.message, exception)
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
fun onNotificationShown(params: WritableMap) {
|
|
85
|
+
//TODO: type ios, android should be same
|
|
86
|
+
sendEvent(reactApplicationContext, "NOTIFICATION_RECEIVED", params)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
fun onNotificationClicked(params: WritableMap) {
|
|
90
|
+
sendEvent(reactApplicationContext, "NOTIFICATION_CLICKED", params)
|
|
18
91
|
}
|
|
19
92
|
|
|
20
93
|
companion object {
|
|
21
94
|
const val NAME = "Comnyx"
|
|
95
|
+
var __self: ComnyxModule? = null
|
|
96
|
+
|
|
97
|
+
fun handleNewIntent(intent: android.content.Intent?) {
|
|
98
|
+
val type = intent?.getStringExtra("comnyx_type")
|
|
99
|
+
if(type != "notification_clicked" && type != "notification_shown") {
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
intent?.let {
|
|
103
|
+
val params = Arguments.createMap()
|
|
104
|
+
it.extras?.let { extras ->
|
|
105
|
+
for (key in extras.keySet()) {
|
|
106
|
+
val value = extras.get(key)
|
|
107
|
+
when (value) {
|
|
108
|
+
is String -> params.putString(key, value)
|
|
109
|
+
is Int -> params.putInt(key, value)
|
|
110
|
+
is Boolean -> params.putBoolean(key, value)
|
|
111
|
+
is Double -> params.putDouble(key, value)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if(type == "notification_clicked"){
|
|
116
|
+
__self?.onNotificationClicked(params)
|
|
117
|
+
|
|
118
|
+
} else {
|
|
119
|
+
__self?.onNotificationShown(params)
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
22
124
|
}
|
|
23
125
|
}
|
|
@@ -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
|
|
13
|
-
ComnyxModule(reactContext)
|
|
14
|
-
|
|
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
|
-
|
|
28
|
+
false // isTurboModule
|
|
29
29
|
)
|
|
30
|
+
|
|
31
|
+
// Add NotificationPermissionModule
|
|
32
|
+
|
|
33
|
+
|
|
30
34
|
moduleInfos
|
|
31
35
|
}
|
|
32
36
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
package com.comnyx.messaging
|
|
2
|
+
|
|
3
|
+
import com.comnyx.src.messaging.permissions.NotificationPermission
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
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
|
+
|
|
26
|
+
public fun checkOptIn(onSuccess: (isGranted: Boolean) -> Unit, onError: (exception: Exception) -> Unit) {
|
|
27
|
+
try {
|
|
28
|
+
val notificationPermission = NotificationPermission(reactApplicationContext)
|
|
29
|
+
val isGranted = notificationPermission.isPermissionGranted()
|
|
30
|
+
onSuccess(isGranted)
|
|
31
|
+
} catch (e: Exception) {
|
|
32
|
+
onError(e)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public fun optIn(onSuccess: (isGranted: Boolean) -> Unit, onError: (exception: Exception) -> Unit) {
|
|
37
|
+
try {
|
|
38
|
+
val notificationPermission = NotificationPermission(reactApplicationContext)
|
|
39
|
+
notificationPermission.requestPermission(onSuccess, onError)
|
|
40
|
+
} catch (e: Exception) {
|
|
41
|
+
onError(e)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
@@ -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,82 @@
|
|
|
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 androidx.core.app.NotificationCompat
|
|
11
|
+
import com.comnyx.ComnyxModule
|
|
12
|
+
import com.facebook.react.bridge.Arguments
|
|
13
|
+
import com.facebook.react.bridge.WritableMap
|
|
14
|
+
|
|
15
|
+
class NotificationsHelper(private val context: Context) {
|
|
16
|
+
|
|
17
|
+
companion object {
|
|
18
|
+
private const val CHANNEL_ID = "COMNYX_NOTIFICATION_CHANNEL"
|
|
19
|
+
private const val NOTIFICATION_ID = 1001
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
init {
|
|
23
|
+
createNotificationChannel()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private fun createNotificationChannel() {
|
|
27
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
28
|
+
val name = "Standard Notifications"
|
|
29
|
+
val description = "Regular notifications channel"
|
|
30
|
+
val importance = NotificationManager.IMPORTANCE_DEFAULT
|
|
31
|
+
val channel = NotificationChannel(CHANNEL_ID, name, importance)
|
|
32
|
+
channel.description = description
|
|
33
|
+
|
|
34
|
+
val notificationManager = context.getSystemService(NotificationManager::class.java)
|
|
35
|
+
channel.apply {
|
|
36
|
+
lightColor = Color.BLUE
|
|
37
|
+
enableLights(true)
|
|
38
|
+
setShowBadge(true)
|
|
39
|
+
enableVibration(true)
|
|
40
|
+
}
|
|
41
|
+
notificationManager.createNotificationChannel(channel)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fun showNotification(title: String, message: String, data: Map<String, String>? = null) {
|
|
46
|
+
// Create pending intent for notification click
|
|
47
|
+
// Use the app's launch intent instead of hardcoding MainActivity
|
|
48
|
+
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
|
|
49
|
+
?: Intent().setPackage(context.packageName)
|
|
50
|
+
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
51
|
+
|
|
52
|
+
// Add all data as extras
|
|
53
|
+
data?.forEach { (key, value) ->
|
|
54
|
+
intent.putExtra(key, value)
|
|
55
|
+
}
|
|
56
|
+
intent.putExtra("comnyx_type", "notification_clicked")
|
|
57
|
+
intent.putExtra("notification_title", title)
|
|
58
|
+
intent.putExtra("notification_message", message)
|
|
59
|
+
|
|
60
|
+
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
|
61
|
+
val builder = NotificationCompat.Builder(context, CHANNEL_ID)
|
|
62
|
+
.setContentTitle(title)
|
|
63
|
+
.setContentText(message)
|
|
64
|
+
.setSmallIcon(android.R.drawable.ic_dialog_info)
|
|
65
|
+
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
|
66
|
+
.setNumber(100)
|
|
67
|
+
.setAutoCancel(true)
|
|
68
|
+
.setContentIntent(pendingIntent)
|
|
69
|
+
|
|
70
|
+
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
71
|
+
notificationManager.notify(NOTIFICATION_ID, builder.build())
|
|
72
|
+
|
|
73
|
+
val writableMap: WritableMap = Arguments.createMap()
|
|
74
|
+
writableMap.putString("comnyx_type", "notification_shown")
|
|
75
|
+
writableMap.putString("notification_title", title)
|
|
76
|
+
writableMap.putString("notification_message", message)
|
|
77
|
+
data?.forEach { (key, value) ->
|
|
78
|
+
writableMap.putString(key, value)
|
|
79
|
+
}
|
|
80
|
+
ComnyxModule.__self?.onNotificationShown(writableMap)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
package com.comnyx.src.messaging.permissions
|
|
2
|
+
|
|
3
|
+
import android.Manifest
|
|
4
|
+
import android.app.Activity
|
|
5
|
+
import android.content.Context
|
|
6
|
+
import android.content.pm.PackageManager
|
|
7
|
+
import android.os.Build
|
|
8
|
+
import androidx.core.app.ActivityCompat
|
|
9
|
+
import androidx.core.content.ContextCompat
|
|
10
|
+
|
|
11
|
+
class NotificationPermission(private val context: Context) {
|
|
12
|
+
companion object {
|
|
13
|
+
private const val PERMISSION_REQUEST_CODE = 100
|
|
14
|
+
private var pendingPromise: ((isGranted: Boolean) -> Unit?)? = null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
public fun isPermissionGranted(): Boolean {
|
|
19
|
+
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
20
|
+
ContextCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED
|
|
21
|
+
} else {
|
|
22
|
+
// On Android 12 and below, notification permission is granted by default
|
|
23
|
+
true
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public fun requestPermission(onSuccess: (isGranted: Boolean) -> Unit, onError: (exception: Exception) -> Unit) {
|
|
28
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
29
|
+
if (!isPermissionGranted()) {
|
|
30
|
+
val activity = context as? Activity
|
|
31
|
+
if (activity == null) {
|
|
32
|
+
onError(Exception("Could not find valid activity"))
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
pendingPromise = onSuccess
|
|
37
|
+
|
|
38
|
+
ActivityCompat.requestPermissions(
|
|
39
|
+
activity,
|
|
40
|
+
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
|
41
|
+
PERMISSION_REQUEST_CODE
|
|
42
|
+
)
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
onSuccess(true)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
public fun onRequestPermissionsResult(
|
|
52
|
+
requestCode: Int,
|
|
53
|
+
permissions: Array<out String>,
|
|
54
|
+
grantResults: IntArray
|
|
55
|
+
) {
|
|
56
|
+
if (requestCode == PERMISSION_REQUEST_CODE) {
|
|
57
|
+
val isGranted = grantResults.isNotEmpty() &&
|
|
58
|
+
grantResults[0] == PackageManager.PERMISSION_GRANTED
|
|
59
|
+
|
|
60
|
+
pendingPromise?.invoke(isGranted)
|
|
61
|
+
pendingPromise = null
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -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,15 @@
|
|
|
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
|
+
@end
|
package/ios/Comnyx.swift
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Comnyx.swift
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Created by Hasbi Sefa Demir on 17.05.2025.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import UserNotifications
|
|
10
|
+
|
|
11
|
+
@objc(Comnyx)
|
|
12
|
+
class Comnyx: RCTEventEmitter {
|
|
13
|
+
private var hasListeners: Bool = false
|
|
14
|
+
var comnyxMessaging: ComnyxMessaging?
|
|
15
|
+
|
|
16
|
+
override init() {
|
|
17
|
+
super.init()
|
|
18
|
+
self.comnyxMessaging = ComnyxMessaging(onNotificationReceived: { notification in
|
|
19
|
+
self.sendEvent(withName: "NOTIFICATION_RECEIVED", body: ["notification": notification])
|
|
20
|
+
}, onNotificationClicked: { response in
|
|
21
|
+
self.sendEvent(withName: "NOTIFICATION_CLICKED", body: ["response": response])
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
deinit {
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
29
|
+
return true
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
override func supportedEvents() -> [String] {
|
|
33
|
+
return ["TOKEN_INIT", "TOKEN_FAILED", "NOTIFICATION_RECEIVED", "NOTIFICATION_CLICKED"]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override func startObserving() {
|
|
37
|
+
hasListeners = true
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override func stopObserving() {
|
|
42
|
+
hasListeners = false
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// MARK: - JavaScript Methods
|
|
49
|
+
|
|
50
|
+
@objc
|
|
51
|
+
func checkOptIn(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
52
|
+
self.comnyxMessaging!.checkOptIn { isAuthorized in
|
|
53
|
+
resolve(isAuthorized)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@objc
|
|
58
|
+
func optIn(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
59
|
+
self.comnyxMessaging!.optIn { granted, initializedAfterOptIn in
|
|
60
|
+
resolve(granted)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@objc
|
|
65
|
+
func initialize(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
66
|
+
self.comnyxMessaging!.initialize(onInitialized: { initialized in
|
|
67
|
+
resolve(initialized)
|
|
68
|
+
}, onApnTokenReceived: { type, token in
|
|
69
|
+
if(type == "failed"){
|
|
70
|
+
self.sendEvent(withName: "TOKEN_FAILED", body: ["type": type, "token": nil])
|
|
71
|
+
}else{
|
|
72
|
+
self.sendEvent(withName: "TOKEN_INIT", body: ["type": type, "token": token])
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|