@developer_tribe/react-native-comnyx 0.7.6 → 0.9.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.
Files changed (108) hide show
  1. package/android/build.gradle +12 -6
  2. package/android/generated/RCTAppDependencyProvider.h +25 -0
  3. package/android/generated/RCTAppDependencyProvider.mm +55 -0
  4. package/android/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  5. package/android/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  6. package/android/generated/RCTThirdPartyComponentsProvider.h +16 -0
  7. package/android/generated/RCTThirdPartyComponentsProvider.mm +23 -0
  8. package/android/generated/ReactAppDependencyProvider.podspec +34 -0
  9. package/android/generated/jni/RNComnyxSpec-generated.cpp +1 -11
  10. package/android/generated/jni/RNComnyxSpec.h +0 -7
  11. package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI-generated.cpp +0 -11
  12. package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI.h +0 -52
  13. package/android/src/main/java/com/comnyx/ComnyxModule.kt +75 -7
  14. package/android/src/main/java/com/comnyx/ComnyxPackage.kt +0 -3
  15. package/android/src/main/java/com/comnyx/src/messaging/firebase/FirebaseMessagingService.kt +1 -9
  16. package/android/src/main/java/com/comnyx/src/messaging/notifications/NotificationsService.kt +105 -8
  17. package/ios/Comnyx.m +2 -2
  18. package/ios/Comnyx.swift +83 -20
  19. package/ios/generated/RCTAppDependencyProvider.h +25 -0
  20. package/ios/generated/RCTAppDependencyProvider.mm +55 -0
  21. package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  22. package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  23. package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
  24. package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
  25. package/ios/generated/RNComnyxSpec/RNComnyxSpec-generated.mm +0 -23
  26. package/ios/generated/RNComnyxSpec/RNComnyxSpec.h +0 -25
  27. package/ios/generated/RNComnyxSpecJSI-generated.cpp +0 -11
  28. package/ios/generated/RNComnyxSpecJSI.h +0 -52
  29. package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
  30. package/lib/commonjs/NativeComnyx.js.map +1 -1
  31. package/lib/commonjs/api/api.js +4 -0
  32. package/lib/commonjs/api/api.js.map +1 -1
  33. package/lib/commonjs/components/ChatList.js +100 -106
  34. package/lib/commonjs/components/ChatList.js.map +1 -1
  35. package/lib/commonjs/components/CustomerForm.js +173 -179
  36. package/lib/commonjs/components/CustomerForm.js.map +1 -1
  37. package/lib/commonjs/components/EmptyList.js +5 -7
  38. package/lib/commonjs/components/EmptyList.js.map +1 -1
  39. package/lib/commonjs/constants/translations.js +145 -29
  40. package/lib/commonjs/constants/translations.js.map +1 -1
  41. package/lib/commonjs/hooks/useLocalize.js +7 -0
  42. package/lib/commonjs/hooks/useLocalize.js.map +1 -1
  43. package/lib/commonjs/notifications/index.js +2 -1
  44. package/lib/commonjs/notifications/index.js.map +1 -1
  45. package/lib/commonjs/notifications/initializeNotifications.js +137 -0
  46. package/lib/commonjs/notifications/initializeNotifications.js.map +1 -0
  47. package/lib/commonjs/register/login.js +1 -1
  48. package/lib/commonjs/register/login.js.map +1 -1
  49. package/lib/commonjs/store/store.js +14 -1
  50. package/lib/commonjs/store/store.js.map +1 -1
  51. package/lib/module/NativeComnyx.js.map +1 -1
  52. package/lib/module/api/api.js +3 -0
  53. package/lib/module/api/api.js.map +1 -1
  54. package/lib/module/components/ChatList.js +101 -107
  55. package/lib/module/components/ChatList.js.map +1 -1
  56. package/lib/module/components/CustomerForm.js +174 -180
  57. package/lib/module/components/CustomerForm.js.map +1 -1
  58. package/lib/module/components/EmptyList.js +6 -8
  59. package/lib/module/components/EmptyList.js.map +1 -1
  60. package/lib/module/constants/translations.js +145 -29
  61. package/lib/module/constants/translations.js.map +1 -1
  62. package/lib/module/hooks/useLocalize.js +6 -0
  63. package/lib/module/hooks/useLocalize.js.map +1 -1
  64. package/lib/module/notifications/index.js +2 -1
  65. package/lib/module/notifications/index.js.map +1 -1
  66. package/lib/module/notifications/initializeNotifications.js +133 -0
  67. package/lib/module/notifications/initializeNotifications.js.map +1 -0
  68. package/lib/module/register/login.js +1 -1
  69. package/lib/module/register/login.js.map +1 -1
  70. package/lib/module/store/store.js +14 -1
  71. package/lib/module/store/store.js.map +1 -1
  72. package/lib/typescript/src/NativeComnyx.d.ts +6 -1
  73. package/lib/typescript/src/NativeComnyx.d.ts.map +1 -1
  74. package/lib/typescript/src/api/api.d.ts +1 -0
  75. package/lib/typescript/src/api/api.d.ts.map +1 -1
  76. package/lib/typescript/src/components/ChatList.d.ts.map +1 -1
  77. package/lib/typescript/src/components/CustomerForm.d.ts.map +1 -1
  78. package/lib/typescript/src/components/EmptyList.d.ts.map +1 -1
  79. package/lib/typescript/src/constants/translations.d.ts.map +1 -1
  80. package/lib/typescript/src/hooks/useLocalize.d.ts +1 -0
  81. package/lib/typescript/src/hooks/useLocalize.d.ts.map +1 -1
  82. package/lib/typescript/src/notifications/index.d.ts +63 -4
  83. package/lib/typescript/src/notifications/index.d.ts.map +1 -1
  84. package/lib/typescript/src/notifications/initializeNotifications.d.ts +7 -0
  85. package/lib/typescript/src/notifications/initializeNotifications.d.ts.map +1 -0
  86. package/lib/typescript/src/store/store.d.ts +4 -0
  87. package/lib/typescript/src/store/store.d.ts.map +1 -1
  88. package/lib/typescript/src/types/Customer.d.ts +5 -0
  89. package/lib/typescript/src/types/Customer.d.ts.map +1 -1
  90. package/lib/typescript/src/types/LocalizationKeys.d.ts +4 -0
  91. package/lib/typescript/src/types/LocalizationKeys.d.ts.map +1 -1
  92. package/package.json +2 -2
  93. package/src/NativeComnyx.ts +6 -1
  94. package/src/api/api.ts +4 -0
  95. package/src/components/ChatList.tsx +110 -123
  96. package/src/components/CustomerForm.tsx +194 -212
  97. package/src/components/EmptyList.tsx +3 -10
  98. package/src/constants/translations.ts +145 -0
  99. package/src/hooks/useLocalize.ts +6 -0
  100. package/src/notifications/index.ts +69 -5
  101. package/src/notifications/initializeNotifications.ts +180 -0
  102. package/src/register/login.ts +1 -1
  103. package/src/store/store.ts +13 -0
  104. package/src/types/Customer.ts +5 -0
  105. package/src/types/LocalizationKeys.ts +4 -0
  106. package/android/generated/java/com/comnyx/NativeComnyxSpec.java +0 -37
  107. package/lib/typescript/setup-jest.d.ts +0 -1
  108. package/lib/typescript/setup-jest.d.ts.map +0 -1
@@ -15,6 +15,7 @@ buildscript {
15
15
  }
16
16
  }
17
17
 
18
+
18
19
  apply plugin: "com.android.library"
19
20
  apply plugin: "kotlin-android"
20
21
  apply plugin: "com.facebook.react"
@@ -90,14 +91,19 @@ dependencies {
90
91
  implementation "com.facebook.react:react-android"
91
92
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
92
93
 
93
- implementation "com.google.firebase:firebase-analytics:21.5.0"
94
94
  api('com.google.firebase:firebase-messaging') {
95
- version {
96
- require '[21.0.0, 23.4.99]'
97
- prefer '23.4.0'
98
- }
95
+ version {
96
+ require '[21.0.0, 23.4.99]'
97
+ prefer '23.4.0'
98
+ }
99
99
  }
100
- }
100
+ api('com.google.firebase:firebase-analytics') {
101
+ version {
102
+ require '[21.0.0, 23.4.99]'
103
+ prefer '23.4.0'
104
+ }
105
+ }
106
+ }
101
107
 
102
108
  react {
103
109
  jsRootDir = file("../src/")
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ #if __has_include(<React-RCTAppDelegate/RCTDependencyProvider.h>)
12
+ #import <React-RCTAppDelegate/RCTDependencyProvider.h>
13
+ #elif __has_include(<React_RCTAppDelegate/RCTDependencyProvider.h>)
14
+ #import <React_RCTAppDelegate/RCTDependencyProvider.h>
15
+ #else
16
+ #import "RCTDependencyProvider.h"
17
+ #endif
18
+
19
+ NS_ASSUME_NONNULL_BEGIN
20
+
21
+ @interface RCTAppDependencyProvider : NSObject <RCTDependencyProvider>
22
+
23
+ @end
24
+
25
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #import "RCTAppDependencyProvider.h"
9
+ #import <ReactCodegen/RCTModulesConformingToProtocolsProvider.h>
10
+ #import <ReactCodegen/RCTThirdPartyComponentsProvider.h>
11
+
12
+ @implementation RCTAppDependencyProvider {
13
+ NSArray<NSString *> * _URLRequestHandlerClassNames;
14
+ NSArray<NSString *> * _imageDataDecoderClassNames;
15
+ NSArray<NSString *> * _imageURLLoaderClassNames;
16
+ NSDictionary<NSString *,Class<RCTComponentViewProtocol>> * _thirdPartyFabricComponents;
17
+ }
18
+
19
+ - (nonnull NSArray<NSString *> *)URLRequestHandlerClassNames {
20
+ static dispatch_once_t requestUrlToken;
21
+ dispatch_once(&requestUrlToken, ^{
22
+ self->_URLRequestHandlerClassNames = RCTModulesConformingToProtocolsProvider.URLRequestHandlerClassNames;
23
+ });
24
+
25
+ return _URLRequestHandlerClassNames;
26
+ }
27
+
28
+ - (nonnull NSArray<NSString *> *)imageDataDecoderClassNames {
29
+ static dispatch_once_t dataDecoderToken;
30
+ dispatch_once(&dataDecoderToken, ^{
31
+ _imageDataDecoderClassNames = RCTModulesConformingToProtocolsProvider.imageDataDecoderClassNames;
32
+ });
33
+
34
+ return _imageDataDecoderClassNames;
35
+ }
36
+
37
+ - (nonnull NSArray<NSString *> *)imageURLLoaderClassNames {
38
+ static dispatch_once_t urlLoaderToken;
39
+ dispatch_once(&urlLoaderToken, ^{
40
+ _imageURLLoaderClassNames = RCTModulesConformingToProtocolsProvider.imageURLLoaderClassNames;
41
+ });
42
+
43
+ return _imageURLLoaderClassNames;
44
+ }
45
+
46
+ - (nonnull NSDictionary<NSString *,Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents {
47
+ static dispatch_once_t nativeComponentsToken;
48
+ dispatch_once(&nativeComponentsToken, ^{
49
+ _thirdPartyFabricComponents = RCTThirdPartyComponentsProvider.thirdPartyFabricComponents;
50
+ });
51
+
52
+ return _thirdPartyFabricComponents;
53
+ }
54
+
55
+ @end
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ @interface RCTModulesConformingToProtocolsProvider: NSObject
11
+
12
+ +(NSArray<NSString *> *)imageURLLoaderClassNames;
13
+
14
+ +(NSArray<NSString *> *)imageDataDecoderClassNames;
15
+
16
+ +(NSArray<NSString *> *)URLRequestHandlerClassNames;
17
+
18
+ @end
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #import "RCTModulesConformingToProtocolsProvider.h"
9
+
10
+ @implementation RCTModulesConformingToProtocolsProvider
11
+
12
+ +(NSArray<NSString *> *)imageURLLoaderClassNames
13
+ {
14
+ return @[
15
+
16
+ ];
17
+ }
18
+
19
+ +(NSArray<NSString *> *)imageDataDecoderClassNames
20
+ {
21
+ return @[
22
+
23
+ ];
24
+ }
25
+
26
+ +(NSArray<NSString *> *)URLRequestHandlerClassNames
27
+ {
28
+ return @[
29
+
30
+ ];
31
+ }
32
+
33
+ @end
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ @protocol RCTComponentViewProtocol;
11
+
12
+ @interface RCTThirdPartyComponentsProvider: NSObject
13
+
14
+ + (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents;
15
+
16
+ @end
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ #import "RCTThirdPartyComponentsProvider.h"
12
+ #import <React/RCTComponentViewProtocol.h>
13
+
14
+ @implementation RCTThirdPartyComponentsProvider
15
+
16
+ + (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents
17
+ {
18
+ return @{
19
+
20
+ };
21
+ }
22
+
23
+ @end
@@ -0,0 +1,34 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ version = "0.78.1"
7
+ source = { :git => 'https://github.com/facebook/react-native.git' }
8
+ if version == '1000.0.0'
9
+ # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
10
+ source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
11
+ else
12
+ source[:tag] = "v#{version}"
13
+ end
14
+
15
+ Pod::Spec.new do |s|
16
+ s.name = "ReactAppDependencyProvider"
17
+ s.version = version
18
+ s.summary = "The third party dependency provider for the app"
19
+ s.homepage = "https://reactnative.dev/"
20
+ s.documentation_url = "https://reactnative.dev/"
21
+ s.license = "MIT"
22
+ s.author = "Meta Platforms, Inc. and its affiliates"
23
+ s.platforms = min_supported_versions
24
+ s.source = source
25
+ s.source_files = "**/RCTAppDependencyProvider.{h,mm}"
26
+
27
+ # This guard prevent to install the dependencies when we run `pod install` in the old architecture.
28
+ s.pod_target_xcconfig = {
29
+ "CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
30
+ "DEFINES_MODULE" => "YES"
31
+ }
32
+
33
+ s.dependency "ReactCodegen"
34
+ end
@@ -12,20 +12,10 @@
12
12
 
13
13
  namespace facebook::react {
14
14
 
15
- static facebook::jsi::Value __hostFunction_NativeComnyxSpecJSI_multiply(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
16
- static jmethodID cachedMethodId = nullptr;
17
- return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, NumberKind, "multiply", "(DD)D", args, count, cachedMethodId);
18
- }
19
15
 
20
- NativeComnyxSpecJSI::NativeComnyxSpecJSI(const JavaTurboModule::InitParams &params)
21
- : JavaTurboModule(params) {
22
- methodMap_["multiply"] = MethodMetadata {2, __hostFunction_NativeComnyxSpecJSI_multiply};
23
- }
24
16
 
25
17
  std::shared_ptr<TurboModule> RNComnyxSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
26
- if (moduleName == "Comnyx") {
27
- return std::make_shared<NativeComnyxSpecJSI>(params);
28
- }
18
+
29
19
  return nullptr;
30
20
  }
31
21
 
@@ -16,13 +16,6 @@
16
16
 
17
17
  namespace facebook::react {
18
18
 
19
- /**
20
- * JNI C++ class for module 'NativeComnyx'
21
- */
22
- class JSI_EXPORT NativeComnyxSpecJSI : public JavaTurboModule {
23
- public:
24
- NativeComnyxSpecJSI(const JavaTurboModule::InitParams &params);
25
- };
26
19
 
27
20
 
28
21
  JSI_EXPORT
@@ -11,18 +11,7 @@
11
11
 
12
12
  namespace facebook::react {
13
13
 
14
- static jsi::Value __hostFunction_NativeComnyxCxxSpecJSI_multiply(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
15
- return static_cast<NativeComnyxCxxSpecJSI *>(&turboModule)->multiply(
16
- rt,
17
- count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber(),
18
- count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asNumber()
19
- );
20
- }
21
14
 
22
- NativeComnyxCxxSpecJSI::NativeComnyxCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
23
- : TurboModule("Comnyx", jsInvoker) {
24
- methodMap_["multiply"] = MethodMetadata {2, __hostFunction_NativeComnyxCxxSpecJSI_multiply};
25
- }
26
15
 
27
16
 
28
17
  } // namespace facebook::react
@@ -15,57 +15,5 @@
15
15
  namespace facebook::react {
16
16
 
17
17
 
18
- class JSI_EXPORT NativeComnyxCxxSpecJSI : public TurboModule {
19
- protected:
20
- NativeComnyxCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
21
-
22
- public:
23
- virtual double multiply(jsi::Runtime &rt, double a, double b) = 0;
24
-
25
- };
26
-
27
- template <typename T>
28
- class JSI_EXPORT NativeComnyxCxxSpec : public TurboModule {
29
- public:
30
- jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
31
- return delegate_.create(rt, propName);
32
- }
33
-
34
- std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
35
- return delegate_.getPropertyNames(runtime);
36
- }
37
-
38
- static constexpr std::string_view kModuleName = "Comnyx";
39
-
40
- protected:
41
- NativeComnyxCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
42
- : TurboModule(std::string{NativeComnyxCxxSpec::kModuleName}, jsInvoker),
43
- delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
44
-
45
-
46
- private:
47
- class Delegate : public NativeComnyxCxxSpecJSI {
48
- public:
49
- Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
50
- NativeComnyxCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
51
-
52
- }
53
-
54
- double multiply(jsi::Runtime &rt, double a, double b) override {
55
- static_assert(
56
- bridging::getParameterCount(&T::multiply) == 3,
57
- "Expected multiply(...) to have 3 parameters");
58
-
59
- return bridging::callFromJs<double>(
60
- rt, &T::multiply, jsInvoker_, instance_, std::move(a), std::move(b));
61
- }
62
-
63
- private:
64
- friend class NativeComnyxCxxSpec;
65
- T *instance_;
66
- };
67
-
68
- Delegate delegate_;
69
- };
70
18
 
71
19
  } // namespace facebook::react
@@ -63,7 +63,13 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
63
63
  if(activity?.intent !== null){
64
64
  ComnyxModule.handleNewIntent(activity.intent)
65
65
  }
66
- promise.resolve(true)
66
+
67
+ val result = Arguments.createMap()
68
+ result.putBoolean("success", true)
69
+ result.putString("country", java.util.Locale.getDefault().country)
70
+ result.putString("timezone", java.util.TimeZone.getDefault().id)
71
+ result.putString("language", java.util.Locale.getDefault().language)
72
+ promise.resolve(result)
67
73
  },
68
74
  { exception ->
69
75
  promise.reject("TOKEN_FAILED", exception.message, exception)
@@ -209,20 +215,82 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
209
215
  }
210
216
  intent?.let {
211
217
  val params = Arguments.createMap()
218
+ params.putString("comnyx_type", type ?: "")
219
+ params.putString("title", it.getStringExtra("title") ?: "")
220
+ params.putString("body", it.getStringExtra("body") ?: "")
221
+ params.putString("subtitle", it.getStringExtra("subtitle") ?: "")
222
+ params.putInt("badge", it.getIntExtra("badge", 0))
223
+ params.putString("sound", it.getStringExtra("sound") ?: "")
224
+
225
+ // Add structured data map
226
+ val dataMap = Arguments.createMap()
212
227
  it.extras?.let { extras ->
213
228
  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)
229
+ // Skip the structured fields we already handled
230
+ if (!key.startsWith("raw_") && !listOf("comnyx_type", "title", "body", "subtitle", "badge", "sound", "data").contains(key)) {
231
+ val value = extras.get(key)
232
+ when (value) {
233
+ is String -> dataMap.putString(key, value)
234
+ is Int -> dataMap.putInt(key, value)
235
+ is Boolean -> dataMap.putBoolean(key, value)
236
+ is Double -> dataMap.putDouble(key, value)
237
+ }
220
238
  }
221
239
  }
222
240
  }
241
+ params.putMap("data", dataMap)
242
+
243
+ // Add raw RemoteMessage data
244
+ val rawMap = Arguments.createMap()
245
+ rawMap.putString("from", it.getStringExtra("raw_from") ?: "")
246
+ rawMap.putString("to", it.getStringExtra("raw_to") ?: "")
247
+ rawMap.putString("messageId", it.getStringExtra("raw_messageId") ?: "")
248
+ rawMap.putString("messageType", it.getStringExtra("raw_messageType") ?: "")
249
+ rawMap.putString("collapseKey", it.getStringExtra("raw_collapseKey") ?: "")
250
+ rawMap.putInt("priority", it.getIntExtra("raw_priority", 0))
251
+ rawMap.putInt("originalPriority", it.getIntExtra("raw_originalPriority", 0))
252
+ rawMap.putInt("ttl", it.getIntExtra("raw_ttl", 0))
253
+ rawMap.putDouble("sentTime", it.getLongExtra("raw_sentTime", 0).toDouble())
254
+
255
+ // Add raw notification data if available
256
+ val notificationMap = Arguments.createMap()
257
+ notificationMap.putString("title", it.getStringExtra("raw_notification_title") ?: "")
258
+ notificationMap.putString("body", it.getStringExtra("raw_notification_body") ?: "")
259
+ notificationMap.putString("icon", it.getStringExtra("raw_notification_icon") ?: "")
260
+ notificationMap.putString("color", it.getStringExtra("raw_notification_color") ?: "")
261
+ notificationMap.putString("sound", it.getStringExtra("raw_notification_sound") ?: "")
262
+ notificationMap.putString("tag", it.getStringExtra("raw_notification_tag") ?: "")
263
+ notificationMap.putString("clickAction", it.getStringExtra("raw_notification_clickAction") ?: "")
264
+ notificationMap.putString("channelId", it.getStringExtra("raw_notification_channelId") ?: "")
265
+ notificationMap.putString("link", it.getStringExtra("raw_notification_link") ?: "")
266
+ notificationMap.putString("ticker", it.getStringExtra("raw_notification_ticker") ?: "")
267
+ notificationMap.putBoolean("sticky", it.getBooleanExtra("raw_notification_sticky", false))
268
+ notificationMap.putBoolean("localOnly", it.getBooleanExtra("raw_notification_localOnly", false))
269
+ notificationMap.putBoolean("defaultSound", it.getBooleanExtra("raw_notification_defaultSound", false))
270
+ notificationMap.putBoolean("defaultVibrateSettings", it.getBooleanExtra("raw_notification_defaultVibrateSettings", false))
271
+ notificationMap.putBoolean("defaultLightSettings", it.getBooleanExtra("raw_notification_defaultLightSettings", false))
272
+
273
+ val vibrateTimings = it.getStringExtra("raw_notification_vibrateTimings")
274
+ if (!vibrateTimings.isNullOrEmpty()) {
275
+ notificationMap.putString("vibrateTimings", vibrateTimings)
276
+ }
277
+
278
+ // Add light settings if available
279
+ if (it.hasExtra("raw_notification_lightColor")) {
280
+ val lightMap = Arguments.createMap()
281
+ lightMap.putInt("color", it.getIntExtra("raw_notification_lightColor", 0))
282
+ lightMap.putInt("onTime", it.getIntExtra("raw_notification_lightOnTime", 0))
283
+ lightMap.putInt("offTime", it.getIntExtra("raw_notification_lightOffTime", 0))
284
+ notificationMap.putMap("lightSettings", lightMap)
285
+ }
286
+
287
+ rawMap.putMap("notification", notificationMap)
288
+ params.putMap("raw", rawMap)
289
+
223
290
  if(type == "notification_clicked"){
224
291
  __self?.onNotificationClicked(params)
225
292
  } else {
293
+ //TODO: remove this
226
294
  __self?.onNotificationShown(params)
227
295
  }
228
296
  }
@@ -27,10 +27,7 @@ class ComnyxPackage : BaseReactPackage() {
27
27
  false, // isCxxModule
28
28
  false // isTurboModule
29
29
  )
30
-
31
30
  // Add NotificationPermissionModule
32
-
33
-
34
31
  moduleInfos
35
32
  }
36
33
  }
@@ -18,21 +18,13 @@ class MyFirebaseMessagingService : FirebaseMessagingService() {
18
18
  override fun onMessageReceived(remoteMessage: RemoteMessage) {
19
19
  //https://stackoverflow.com/a/40083727
20
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)
21
+ notificationsHelper.showNotification(remoteMessage)
26
22
  }
27
23
 
28
-
29
-
30
-
31
24
  override fun onNewToken(token: String) {
32
25
  sendRegistrationToServer(token)
33
26
  }
34
27
 
35
-
36
28
  private fun sendRegistrationToServer(token: String) {
37
29
  //TODO: send token to server
38
30
  Log.d("MyFirebaseMessagingService","sendRegistrationTokenToServer($token)")
@@ -12,6 +12,7 @@ import androidx.core.app.NotificationCompat
12
12
  import com.comnyx.ComnyxModule
13
13
  import com.facebook.react.bridge.Arguments
14
14
  import com.facebook.react.bridge.WritableMap
15
+ import com.google.firebase.messaging.RemoteMessage
15
16
 
16
17
  class NotificationsHelper(private val context: Context) {
17
18
 
@@ -49,9 +50,15 @@ class NotificationsHelper(private val context: Context) {
49
50
  }
50
51
  }
51
52
 
52
- fun showNotification(title: String, message: String, data: Map<String, String>? = null) {
53
- Log.d(TAG, "Showing notification - Title: $title, Message: $message")
54
-
53
+ fun showNotification(remoteMessage: RemoteMessage) {
54
+ Log.d(TAG, "Showing notification - Title: ${remoteMessage.notification?.title}, Message: ${remoteMessage.notification?.body}")
55
+ val title: String = remoteMessage.data["title"] ?: remoteMessage.notification?.title ?: ""
56
+ val message: String = remoteMessage.data["body"] ?: remoteMessage.notification?.body ?: ""
57
+ val subtitle: String = remoteMessage.data["subtitle"] ?: remoteMessage.notification?.bodyLocalizationKey ?: ""
58
+ val badge: Int = remoteMessage.data["badge"]?.toIntOrNull() ?: 0
59
+ val sound: String = remoteMessage.data["sound"] ?: remoteMessage.notification?.sound ?: ""
60
+ val data: Map<String, String>? = remoteMessage.data
61
+
55
62
  // Create pending intent for notification click
56
63
  val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
57
64
  ?: Intent().setPackage(context.packageName)
@@ -65,8 +72,50 @@ class NotificationsHelper(private val context: Context) {
65
72
  intent.putExtra(key, value)
66
73
  }
67
74
  intent.putExtra("comnyx_type", "notification_clicked")
68
- intent.putExtra("notification_title", title)
69
- intent.putExtra("notification_message", message)
75
+ intent.putExtra("title", title)
76
+ intent.putExtra("body", message)
77
+ intent.putExtra("subtitle", subtitle)
78
+ intent.putExtra("badge", badge)
79
+ intent.putExtra("sound", sound)
80
+ intent.putExtra("data", remoteMessage.data.toString())
81
+
82
+ // Add all raw RemoteMessage data
83
+ intent.putExtra("raw_from", remoteMessage.from ?: "")
84
+ intent.putExtra("raw_to", remoteMessage.to ?: "")
85
+ intent.putExtra("raw_messageId", remoteMessage.messageId ?: "")
86
+ intent.putExtra("raw_messageType", remoteMessage.messageType ?: "")
87
+ intent.putExtra("raw_collapseKey", remoteMessage.collapseKey ?: "")
88
+ intent.putExtra("raw_priority", remoteMessage.priority)
89
+ intent.putExtra("raw_originalPriority", remoteMessage.originalPriority)
90
+ intent.putExtra("raw_ttl", remoteMessage.ttl)
91
+ intent.putExtra("raw_sentTime", remoteMessage.sentTime)
92
+
93
+ // Add raw notification data if available
94
+ remoteMessage.notification?.let { notification ->
95
+ intent.putExtra("raw_notification_title", notification.title ?: "")
96
+ intent.putExtra("raw_notification_body", notification.body ?: "")
97
+ intent.putExtra("raw_notification_icon", notification.icon ?: "")
98
+ intent.putExtra("raw_notification_color", notification.color ?: "")
99
+ intent.putExtra("raw_notification_sound", notification.sound ?: "")
100
+ intent.putExtra("raw_notification_tag", notification.tag ?: "")
101
+ intent.putExtra("raw_notification_clickAction", notification.clickAction ?: "")
102
+ intent.putExtra("raw_notification_channelId", notification.channelId ?: "")
103
+ intent.putExtra("raw_notification_link", notification.link?.toString() ?: "")
104
+ intent.putExtra("raw_notification_ticker", notification.ticker ?: "")
105
+ intent.putExtra("raw_notification_sticky", notification.sticky)
106
+ intent.putExtra("raw_notification_localOnly", notification.localOnly)
107
+ intent.putExtra("raw_notification_defaultSound", notification.defaultSound)
108
+ intent.putExtra("raw_notification_defaultVibrateSettings", notification.defaultVibrateSettings)
109
+ intent.putExtra("raw_notification_defaultLightSettings", notification.defaultLightSettings)
110
+ notification.vibrateTimings?.let { vibrate ->
111
+ intent.putExtra("raw_notification_vibrateTimings", vibrate.contentToString())
112
+ }
113
+ notification.lightSettings?.let { light ->
114
+ intent.putExtra("raw_notification_lightColor", light[0])
115
+ intent.putExtra("raw_notification_lightOnTime", light[1])
116
+ intent.putExtra("raw_notification_lightOffTime", light[2])
117
+ }
118
+ }
70
119
 
71
120
  try {
72
121
  val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
@@ -85,11 +134,59 @@ class NotificationsHelper(private val context: Context) {
85
134
 
86
135
  val writableMap: WritableMap = Arguments.createMap()
87
136
  writableMap.putString("comnyx_type", "notification_shown")
88
- writableMap.putString("notification_title", title)
89
- writableMap.putString("notification_message", message)
137
+ writableMap.putString("title", title)
138
+ writableMap.putString("body", message)
139
+ writableMap.putString("subtitle", subtitle)
140
+ writableMap.putInt("badge", badge)
141
+ writableMap.putString("sound", sound)
142
+ val dataMap = Arguments.createMap()
90
143
  data?.forEach { (key, value) ->
91
- writableMap.putString(key, value)
144
+ dataMap.putString(key, value)
145
+ }
146
+ writableMap.putMap("data", dataMap)
147
+
148
+ val rawMap = Arguments.createMap()
149
+ rawMap.putString("from", remoteMessage.from ?: "")
150
+ rawMap.putString("to", remoteMessage.to ?: "")
151
+ rawMap.putString("messageId", remoteMessage.messageId ?: "")
152
+ rawMap.putString("messageType", remoteMessage.messageType ?: "")
153
+ rawMap.putString("collapseKey", remoteMessage.collapseKey ?: "")
154
+ rawMap.putInt("priority", remoteMessage.priority)
155
+ rawMap.putInt("originalPriority", remoteMessage.originalPriority)
156
+ rawMap.putInt("ttl", remoteMessage.ttl)
157
+ rawMap.putDouble("sentTime", remoteMessage.sentTime.toDouble())
158
+
159
+ // Add raw notification data if available
160
+ remoteMessage.notification?.let { notification ->
161
+ val notificationMap = Arguments.createMap()
162
+ notificationMap.putString("title", notification.title ?: "")
163
+ notificationMap.putString("body", notification.body ?: "")
164
+ notificationMap.putString("icon", notification.icon ?: "")
165
+ notificationMap.putString("color", notification.color ?: "")
166
+ notificationMap.putString("sound", notification.sound ?: "")
167
+ notificationMap.putString("tag", notification.tag ?: "")
168
+ notificationMap.putString("clickAction", notification.clickAction ?: "")
169
+ notificationMap.putString("channelId", notification.channelId ?: "")
170
+ notificationMap.putString("link", notification.link?.toString() ?: "")
171
+ notificationMap.putString("ticker", notification.ticker ?: "")
172
+ notificationMap.putBoolean("sticky", notification.sticky)
173
+ notificationMap.putBoolean("localOnly", notification.localOnly)
174
+ notificationMap.putBoolean("defaultSound", notification.defaultSound)
175
+ notificationMap.putBoolean("defaultVibrateSettings", notification.defaultVibrateSettings)
176
+ notificationMap.putBoolean("defaultLightSettings", notification.defaultLightSettings)
177
+ notification.vibrateTimings?.let { vibrate ->
178
+ notificationMap.putString("vibrateTimings", vibrate.contentToString())
179
+ }
180
+ notification.lightSettings?.let { light ->
181
+ val lightMap = Arguments.createMap()
182
+ lightMap.putInt("color", light[0])
183
+ lightMap.putInt("onTime", light[1])
184
+ lightMap.putInt("offTime", light[2])
185
+ notificationMap.putMap("lightSettings", lightMap)
186
+ }
187
+ rawMap.putMap("notification", notificationMap)
92
188
  }
189
+ writableMap.putMap("raw", rawMap)
93
190
  ComnyxModule.__self?.onNotificationShown(writableMap)
94
191
  Log.d(TAG, "Notification event sent to JS")
95
192
  } catch (e: Exception) {
package/ios/Comnyx.m CHANGED
@@ -10,9 +10,9 @@ RCT_EXTERN_METHOD(optIn:(RCTPromiseResolveBlock)resolve
10
10
  reject:(RCTPromiseRejectBlock)reject)
11
11
 
12
12
  RCT_EXTERN_METHOD(initialize:(RCTPromiseResolveBlock)resolve
13
- rejecter:(RCTPromiseRejectBlock)reject)
13
+ reject:(RCTPromiseRejectBlock)reject)
14
14
 
15
15
  RCT_EXTERN_METHOD(linkToSettings:(RCTPromiseResolveBlock)resolve
16
16
  reject:(RCTPromiseRejectBlock)reject)
17
17
 
18
- @end
18
+ @end