@adobe/react-native-aepmessaging 5.0.0 → 6.0.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 (61) hide show
  1. package/.babelrc +1 -1
  2. package/RCTAEPMessaging.podspec +26 -8
  3. package/README.md +93 -10
  4. package/android/build.gradle +84 -22
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +0 -2
  7. package/android/src/main/AndroidManifestNew.xml +2 -0
  8. package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingModule.java +215 -202
  9. package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingPackage.java +27 -25
  10. package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingUtil.java +134 -0
  11. package/dist/Messaging.d.ts +62 -0
  12. package/dist/Messaging.js +118 -0
  13. package/dist/Messaging.js.map +1 -0
  14. package/{js → dist}/index.d.ts +3 -1
  15. package/{js → dist}/index.js +4 -2
  16. package/dist/index.js.map +1 -0
  17. package/dist/models/Message.d.ts +39 -0
  18. package/dist/models/Message.js +64 -0
  19. package/dist/models/Message.js.map +1 -0
  20. package/dist/models/MessagingDelegate.d.ts +35 -0
  21. package/{js → dist}/models/MessagingDelegate.js +1 -1
  22. package/dist/models/MessagingDelegate.js.map +1 -0
  23. package/{js → dist}/models/MessagingEdgeEventType.d.ts +4 -4
  24. package/{js → dist}/models/MessagingEdgeEventType.js +5 -5
  25. package/dist/models/MessagingEdgeEventType.js.map +1 -0
  26. package/dist/models/MessagingProposition.d.ts +8 -0
  27. package/dist/models/MessagingProposition.js +24 -0
  28. package/dist/models/MessagingProposition.js.map +1 -0
  29. package/dist/models/MessagingPropositionItem.d.ts +8 -0
  30. package/dist/models/MessagingPropositionItem.js +14 -0
  31. package/dist/models/MessagingPropositionItem.js.map +1 -0
  32. package/ios/src/RCTAEPMessaging-Bridging-Header.h +15 -0
  33. package/ios/src/RCTAEPMessaging.mm +50 -0
  34. package/ios/src/RCTAEPMessaging.swift +266 -0
  35. package/ios/src/RCTAEPMessagingConstants.swift +22 -0
  36. package/ios/src/RCTAEPMessagingDataBridge.swift +47 -0
  37. package/package.json +6 -6
  38. package/src/Messaging.ts +164 -0
  39. package/{ts → src}/index.ts +11 -2
  40. package/src/models/Message.ts +72 -0
  41. package/src/models/MessagingDelegate.ts +53 -0
  42. package/{ts → src}/models/MessagingEdgeEventType.ts +5 -5
  43. package/src/models/MessagingProposition.ts +32 -0
  44. package/src/models/MessagingPropositionItem.ts +20 -0
  45. package/tsconfig.json +2 -2
  46. package/ios/RCTAEPMessaging.xcodeproj/project.pbxproj +0 -304
  47. package/ios/src/RCTAEPMessaging.h +0 -20
  48. package/ios/src/RCTAEPMessaging.m +0 -196
  49. package/js/Messaging.d.ts +0 -32
  50. package/js/Messaging.js +0 -80
  51. package/js/Messaging.js.map +0 -1
  52. package/js/index.js.map +0 -1
  53. package/js/models/Message.d.ts +0 -43
  54. package/js/models/Message.js +0 -80
  55. package/js/models/Message.js.map +0 -1
  56. package/js/models/MessagingDelegate.d.ts +0 -25
  57. package/js/models/MessagingDelegate.js.map +0 -1
  58. package/js/models/MessagingEdgeEventType.js.map +0 -1
  59. package/ts/Messaging.ts +0 -99
  60. package/ts/models/Message.ts +0 -82
  61. package/ts/models/MessagingDelegate.ts +0 -41
@@ -1,253 +1,266 @@
1
1
  /*
2
- Copyright 2022 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- Unless required by applicable law or agreed to in writing, software distributed under
7
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8
- OF ANY KIND, either express or implied. See the License for the specific language
9
- governing permissions and limitations under the License.
2
+ Copyright 2023 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the
4
+ "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
7
+ or agreed to in writing, software distributed under the License is
8
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
9
+ ANY KIND, either express or implied. See the License for the specific
10
+ language governing permissions and limitations under the License.
10
11
  */
11
12
  package com.adobe.marketing.mobile.reactnative.messaging;
12
13
 
13
- import com.adobe.marketing.mobile.AdobeCallback;
14
- import com.adobe.marketing.mobile.LoggingMode;
15
-
16
- import static com.adobe.marketing.mobile.LoggingMode.DEBUG;
17
- import static com.adobe.marketing.mobile.LoggingMode.VERBOSE;
14
+ import android.app.Activity;
18
15
 
19
- import android.util.Log;
16
+ import androidx.annotation.NonNull;
20
17
 
18
+ import com.adobe.marketing.mobile.AdobeCallback;
19
+ import com.adobe.marketing.mobile.AdobeCallbackWithError;
20
+ import com.adobe.marketing.mobile.AdobeError;
21
+ import com.adobe.marketing.mobile.LoggingMode;
21
22
  import com.adobe.marketing.mobile.Message;
22
23
  import com.adobe.marketing.mobile.Messaging;
23
24
  import com.adobe.marketing.mobile.MessagingEdgeEventType;
24
25
  import com.adobe.marketing.mobile.MobileCore;
25
- import com.adobe.marketing.mobile.services.MessagingDelegate;
26
- import com.adobe.marketing.mobile.services.ui.FullscreenMessage;
26
+ import com.adobe.marketing.mobile.messaging.MessagingUtils;
27
+ import com.adobe.marketing.mobile.messaging.Proposition;
28
+ import com.adobe.marketing.mobile.messaging.Surface;
29
+ import com.adobe.marketing.mobile.services.ServiceProvider;
30
+ import com.adobe.marketing.mobile.services.ui.InAppMessage;
31
+ import com.adobe.marketing.mobile.services.ui.Presentable;
32
+ import com.adobe.marketing.mobile.services.ui.PresentationDelegate;
27
33
  import com.facebook.react.bridge.Arguments;
28
34
  import com.facebook.react.bridge.Promise;
29
35
  import com.facebook.react.bridge.ReactApplicationContext;
30
36
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
31
37
  import com.facebook.react.bridge.ReactMethod;
38
+ import com.facebook.react.bridge.ReadableArray;
32
39
  import com.facebook.react.bridge.WritableMap;
33
40
  import com.facebook.react.modules.core.DeviceEventManagerModule;
34
-
35
41
  import java.util.HashMap;
42
+ import java.util.List;
36
43
  import java.util.Map;
37
44
  import java.util.concurrent.CountDownLatch;
38
45
 
39
- public final class RCTAEPMessagingModule extends ReactContextBaseJavaModule implements MessagingDelegate {
40
-
41
- private static final String TAG = "RCTAEPMessagingModule";
42
- private final Map<String, Message> messageCache;
43
- private final ReactApplicationContext reactContext;
44
- private boolean shouldSaveMessage;
45
- private boolean shouldShowMessage;
46
- private CountDownLatch latch = new CountDownLatch(1);
47
-
48
- public RCTAEPMessagingModule(ReactApplicationContext reactContext) {
49
- super(reactContext);
50
- this.reactContext = reactContext;
51
- this.messageCache = new HashMap<>();
52
- this.shouldShowMessage = false;
53
- this.shouldSaveMessage = false;
54
- }
46
+ public final class RCTAEPMessagingModule
47
+ extends ReactContextBaseJavaModule implements PresentationDelegate {
55
48
 
56
- @Override
57
- public String getName() {
58
- return "AEPMessaging";
59
- }
49
+ private static final String TAG = "RCTAEPMessagingModule";
50
+ private final Map<String, Message> messageCache = new HashMap<>();
51
+ private final ReactApplicationContext reactContext;
52
+ private boolean shouldSaveMessage = false;
53
+ private boolean shouldShowMessage = false;
54
+ private CountDownLatch latch = new CountDownLatch(1);
55
+ private Message latestMessage = null;
56
+
57
+ public RCTAEPMessagingModule(ReactApplicationContext reactContext) {
58
+ super(reactContext);
59
+ this.reactContext = reactContext;
60
+ }
61
+
62
+ @Override
63
+ public String getName() {
64
+ return "AEPMessaging";
65
+ }
66
+
67
+ // Required for rn built in EventEmitter Calls.
68
+ @ReactMethod
69
+ public void addListener(String eventName) {}
60
70
 
61
- // Required for rn built in EventEmitter Calls.
62
- @ReactMethod
63
- public void addListener(String eventName) {}
71
+ @ReactMethod
72
+ public void removeListeners(Integer count) {}
64
73
 
65
- @ReactMethod
66
- public void removeListeners(Integer count) {}
74
+ @ReactMethod
75
+ public void extensionVersion(final Promise promise) {
76
+ promise.resolve(Messaging.extensionVersion());
77
+ }
67
78
 
68
- @ReactMethod
69
- public void extensionVersion(final Promise promise) {
70
- MobileCore.log(VERBOSE, TAG, "extensionVersion is called");
71
- promise.resolve(Messaging.extensionVersion());
79
+ @ReactMethod
80
+ public void getCachedMessages(final Promise promise) {
81
+ promise.resolve(
82
+ RCTAEPMessagingUtil.convertMessagesToJS(this.messageCache.values()));
83
+ }
84
+
85
+ @ReactMethod
86
+ public void getLatestMessage(final Promise promise) {
87
+ promise.resolve(this.latestMessage);
88
+ }
89
+
90
+ @ReactMethod
91
+ public void getPropositionsForSurfaces(ReadableArray surfaces,
92
+ final Promise promise) {
93
+ String bundleId = this.reactContext.getPackageName();
94
+ Messaging.getPropositionsForSurfaces(
95
+ RCTAEPMessagingUtil.convertSurfaces(surfaces),
96
+ new AdobeCallbackWithError<Map<Surface, List<Proposition>>>() {
97
+ @Override
98
+ public void fail(final AdobeError adobeError) {
99
+ promise.reject(adobeError.getErrorName(),
100
+ "Unable to get Propositions");
101
+ }
102
+
103
+ @Override
104
+ public void call(
105
+ Map<Surface, List<Proposition>> propositionsMap) {
106
+ promise.resolve(RCTAEPMessagingUtil.convertSurfacePropositions(
107
+ propositionsMap, bundleId));
108
+ }
109
+ });
110
+ }
111
+
112
+ @ReactMethod
113
+ public void refreshInAppMessages() {
114
+ Messaging.refreshInAppMessages();
115
+ }
116
+
117
+ @ReactMethod
118
+ public void setMessagingDelegate() {
119
+ ServiceProvider.getInstance().getUIService().setPresentationDelegate(this);
120
+ }
121
+
122
+ @ReactMethod
123
+ public void updatePropositionsForSurfaces(ReadableArray surfaces) {
124
+ Messaging.updatePropositionsForSurfaces(
125
+ RCTAEPMessagingUtil.convertSurfaces(surfaces));
126
+ }
127
+
128
+ // Message Methods
129
+
130
+ @ReactMethod
131
+ public void clear(final String messageId) {
132
+ if (messageId != null) {
133
+ messageCache.remove(messageId);
72
134
  }
135
+ }
73
136
 
74
- @ReactMethod
75
- public void refreshInAppMessages() {
76
- MobileCore.log(VERBOSE, TAG, "refreshInAppMessages is called");
77
- Messaging.refreshInAppMessages();
137
+ @ReactMethod
138
+ public void dismiss(final String messageId) {
139
+ if (messageId != null && messageCache.get(messageId) != null) {
140
+ messageCache.get(messageId).dismiss();
78
141
  }
142
+ }
79
143
 
80
- @ReactMethod
81
- public void setMessagingDelegate() {
82
- MobileCore.log(VERBOSE, TAG, "setMessagingDelegate is called");
83
- MobileCore.setMessagingDelegate(this);
144
+ @ReactMethod
145
+ public void setAutoTrack(final String messageId, final boolean autoTrack) {
146
+ if (messageId != null && messageCache.get(messageId) != null) {
147
+ messageCache.get(messageId).setAutoTrack(autoTrack);
84
148
  }
149
+ }
85
150
 
86
- @ReactMethod
87
- public void show(final String messageId) {
88
- if (messageId != null && messageCache.get(messageId) != null) {
89
- MobileCore.log(VERBOSE, TAG, String.format("show is called with message id: %s", messageId));
90
- messageCache.get(messageId).show();
91
- }
151
+ @ReactMethod
152
+ public void show(final String messageId) {
153
+ if (messageId != null && messageCache.get(messageId) != null) {
154
+ messageCache.get(messageId).show();
92
155
  }
156
+ }
93
157
 
94
- @ReactMethod
95
- public void dismiss(final String messageId, final boolean suppressAutoTrack) {
96
- if (messageId != null && messageCache.get(messageId) != null) {
97
- MobileCore.log(VERBOSE, TAG, String.format("dismiss is called with message id: %s and suppressAutoTrack: %b", messageId, suppressAutoTrack));
98
- messageCache.get(messageId).dismiss(suppressAutoTrack);
99
- }
158
+ @ReactMethod
159
+ public void track(final String messageId, final String interaction,
160
+ final int eventType) {
161
+ if (messageId != null && messageCache.get(messageId) != null) {
162
+ MessagingEdgeEventType edgeEventType =
163
+ RCTAEPMessagingUtil.getEventType(eventType);
164
+ if (edgeEventType != null) {
165
+ messageCache.get(messageId).track(interaction, edgeEventType);
166
+ }
100
167
  }
168
+ }
101
169
 
102
- @ReactMethod
103
- public void track(final String messageId, final String interaction, final int eventType) {
104
- if (messageId != null && messageCache.get(messageId) != null) {
105
- MobileCore.log(VERBOSE, TAG, String.format("track is called with message id: %s, interaction: %s and eventType: %d", messageId, interaction, eventType));
106
- MessagingEdgeEventType edgeEventType = null;
107
- switch (eventType) {
108
- case 0:
109
- edgeEventType = MessagingEdgeEventType.IN_APP_DISMISS;
110
- break;
111
- case 1:
112
- edgeEventType = MessagingEdgeEventType.IN_APP_INTERACT;
113
- break;
114
- case 2:
115
- edgeEventType = MessagingEdgeEventType.IN_APP_TRIGGER;
116
- break;
117
- case 3:
118
- edgeEventType = MessagingEdgeEventType.IN_APP_DISPLAY;
119
- break;
120
- case 4:
121
- edgeEventType = MessagingEdgeEventType.PUSH_APPLICATION_OPENED;
122
- break;
123
- case 5:
124
- edgeEventType = MessagingEdgeEventType.PUSH_CUSTOM_ACTION;
125
- break;
126
- default:
127
- break;
128
- }
129
- if (edgeEventType != null) {
130
- messageCache.get(messageId).track(interaction, edgeEventType);
131
- } else {
132
- MobileCore.log(DEBUG, TAG, String.format("Unable to track interaction (%s) because edgeEventType (%d) is invalid ", interaction, eventType));
133
- }
134
- }
170
+ // Messaging Delegate functions
171
+ @Override
172
+ public void onShow(final Presentable<?> presentable) {
173
+ if (!(presentable.getPresentation() instanceof InAppMessage)) return;
174
+ Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
175
+ if (message != null) {
176
+ Map<String, String> data =
177
+ RCTAEPMessagingUtil.convertMessageToMap(message);
178
+ emitEvent("onShow", data);
135
179
  }
180
+ }
136
181
 
137
- @ReactMethod
138
- public void handleJavascriptMessage(final String messageId, final String messageName, final Promise promise) {
139
- if (messageId != null && messageCache.get(messageId) != null) {
140
- MobileCore.log(VERBOSE, TAG, String.format("handleJavascriptMessage is called with message id: %s and messageName: %s", messageId, messageName));
141
- messageCache.get(messageId).handleJavascriptMessage(messageName, new AdobeCallback<String>() {
142
- @Override
143
- public void call(final String s) {
144
- if (s != null) {
145
- promise.resolve(s);
146
- } else {
147
- promise.reject("error", "error in handling javascriptMessage " + messageName);
148
- }
149
- }
150
- });
151
- }
182
+ @Override
183
+ public void onDismiss(final Presentable<?> presentable) {
184
+ if (!(presentable.getPresentation() instanceof InAppMessage)) return;
185
+ Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
186
+ if (message != null) {
187
+ Map<String, String> data =
188
+ RCTAEPMessagingUtil.convertMessageToMap(message);
189
+ emitEvent("onDismiss", data);
152
190
  }
191
+ }
153
192
 
154
- @ReactMethod
155
- public void clear(final String messageId) {
156
- if (messageId != null) {
157
- MobileCore.log(VERBOSE, TAG, String.format("clear is called with message id: %s", messageId));
158
- messageCache.remove(messageId);
159
- }
193
+ @Override
194
+ public void onHide(final Presentable<?> presentable) {
195
+ if (!(presentable.getPresentation() instanceof InAppMessage)) return;
196
+ Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
197
+ if (message != null) {
198
+ Map<String, String> data =
199
+ RCTAEPMessagingUtil.convertMessageToMap(message);
200
+ emitEvent("onHide", data);
160
201
  }
202
+ }
161
203
 
162
- @ReactMethod
163
- public void setAutoTrack(final String messageId, final boolean autoTrack) {
164
- if (messageId != null && messageCache.get(messageId) != null) {
165
- MobileCore.log(VERBOSE, TAG, String.format("setAutoTrack is called with message id: %s and autoTrack: %b", messageId, autoTrack));
166
- messageCache.get(messageId).setAutoTrack(autoTrack);
167
- }
204
+ @Override
205
+ public boolean canShow(final Presentable<?> presentable) {
206
+ if (!(presentable.getPresentation() instanceof InAppMessage)) return false;
207
+ Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
208
+ if (message != null) {
209
+ Map<String, String> data =
210
+ RCTAEPMessagingUtil.convertMessageToMap(message);
211
+ emitEvent("shouldShowMessage", data);
212
+ // Latch stops the thread until the shouldShowMessage value is received
213
+ // from the JS side on thread dedicated to run JS code. The function
214
+ // called from JS that resumes the thread is "shouldShowMessage".
215
+ try {
216
+ latch.await();
217
+ } catch (final InterruptedException e) {
218
+ }
168
219
  }
169
220
 
170
- @ReactMethod(isBlockingSynchronousMethod = true)
171
- public void shouldShowMessage(final boolean shouldShowMessage, final boolean shouldSaveMessage) {
172
- MobileCore.log(VERBOSE, TAG, String.format("shouldShowMessage is called with message id: %b and shouldSaveMessage: %b", shouldShowMessage, shouldSaveMessage));
173
- this.shouldShowMessage = shouldShowMessage;
174
- this.shouldSaveMessage = shouldSaveMessage;
175
- latch.countDown();
221
+ if (shouldShowMessage) {
222
+ this.latestMessage = message;
176
223
  }
177
224
 
178
- //Messaging Delegate functions
179
- @Override
180
- public void onShow(final FullscreenMessage fullscreenMessage) {
181
- MobileCore.log(VERBOSE, TAG, "onShow is called");
182
- final Message message = (Message) fullscreenMessage.getParent();
183
- if (message != null) {
184
- Map<String, String> data = new HashMap<>();
185
- data.put("id", message.getId());
186
- data.put("autoTrack", String.valueOf(message.getAutoTrack()));
187
- emitEvent("onShow", data);
188
- }
225
+ if (shouldSaveMessage) {
226
+ messageCache.put(message.getId(), message);
189
227
  }
190
228
 
191
- @Override
192
- public void onDismiss(final FullscreenMessage fullscreenMessage) {
193
- MobileCore.log(VERBOSE, TAG, "onDismiss is called");
194
- final Message message = (Message) fullscreenMessage.getParent();
195
- if (message != null) {
196
- Map<String, String> data = new HashMap<>();
197
- data.put("id", message.getId());
198
- data.put("autoTrack", String.valueOf(message.getAutoTrack()));
199
- emitEvent("onDismiss", data);
200
- }
229
+ return shouldShowMessage;
230
+ }
231
+
232
+ public void onContentLoaded(final Presentable<?> presentable, PresentationContent presentationContent) {
233
+ if (!(presentable.getPresentation() instanceof InAppMessage)) return;
234
+ Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
235
+ if (message != null) {
236
+ Map<String, String> data =
237
+ RCTAEPMessagingUtil.convertMessageToMap(message);
238
+ emitEvent("onContentLoaded", data);
201
239
  }
240
+ }
241
+
242
+ // Messaging Delegate Callback
243
+ @ReactMethod(isBlockingSynchronousMethod = true)
244
+ public void setMessageSettings(final boolean shouldShowMessage,
245
+ final boolean shouldSaveMessage) {
246
+ this.shouldShowMessage = shouldShowMessage;
247
+ this.shouldSaveMessage = shouldSaveMessage;
248
+ latch.countDown();
249
+ }
202
250
 
203
- @Override
204
- public boolean shouldShowMessage(final FullscreenMessage fullscreenMessage) {
205
- MobileCore.log(VERBOSE, TAG, "shouldShowMessage is called");
206
- final Message message = (Message) fullscreenMessage.getParent();
207
- if (message != null) {
208
- Map<String, String> data = new HashMap<>();
209
- data.put("id", message.getId());
210
- data.put("autoTrack", String.valueOf(message.getAutoTrack()));
211
- emitEvent("shouldShowMessage", data);
212
- //Latch stops the thread until the shouldShowMessage value is received from the JS side on thread dedicated to run JS code. The function called from JS that resumes the thread is "shouldShowMessage".
213
- MobileCore.log(VERBOSE, TAG, "shouldShowMessage: Thread is locked.");
214
- try {
215
- latch.await();
216
- } catch (final InterruptedException e) {
217
- MobileCore.log(LoggingMode.ERROR, TAG, String.format("CountDownLatch await Interrupted: (%s)", e.getLocalizedMessage()));
218
- }
219
- MobileCore.log(VERBOSE, TAG, "shouldShowMessage: Thread is resumed.");
220
- if (shouldSaveMessage) {
221
- messageCache.put(message.getId(), message);
222
- }
223
- }
224
- return shouldShowMessage;
225
- }
226
-
227
- @Override
228
- public void urlLoaded(String url, FullscreenMessage fullscreenMessage) {
229
- MobileCore.log(VERBOSE, TAG, String.format("overrideUrlLoad is called with url: (%s)", url));
230
- final Message message = (Message) fullscreenMessage.getParent();
231
- if (message != null) {
232
- Map<String, String> data = new HashMap<>();
233
- data.put("id", message.getId());
234
- data.put("autoTrack", String.valueOf(message.getAutoTrack()));
235
- data.put("url", url);
236
- emitEvent("urlLoaded", data);
237
- }
238
- }
239
-
240
- /**
241
- * Emits an event along with data to be handled by the Javascript
242
- *
243
- * @param name event name
244
- * @param data data sent along with event
245
- */
246
- private void emitEvent(final String name, final Map<String, String> data) {
247
- WritableMap eventData = Arguments.createMap();
248
- for (final Map.Entry<String, String> entry : data.entrySet()) {
249
- eventData.putString(entry.getKey(), entry.getValue());
250
- }
251
- reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(name, eventData);
251
+ /**
252
+ * Emits an event along with data to be handled by the Javascript
253
+ *
254
+ * @param name event name
255
+ * @param data data sent along with event
256
+ */
257
+ private void emitEvent(final String name, final Map<String, String> data) {
258
+ WritableMap eventData = Arguments.createMap();
259
+ for (final Map.Entry<String, String> entry : data.entrySet()) {
260
+ eventData.putString(entry.getKey(), entry.getValue());
252
261
  }
262
+ reactContext
263
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
264
+ .emit(name, eventData);
265
+ }
253
266
  }
@@ -1,38 +1,40 @@
1
1
  /*
2
- Copyright 2022 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- Unless required by applicable law or agreed to in writing, software distributed under
7
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8
- OF ANY KIND, either express or implied. See the License for the specific language
9
- governing permissions and limitations under the License.
2
+ Copyright 2023 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the
4
+ "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
7
+ or agreed to in writing, software distributed under the License is distributed
8
+ on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either
9
+ express or implied. See the License for the specific language governing
10
+ permissions and limitations under the License.
10
11
  */
11
12
  package com.adobe.marketing.mobile.reactnative.messaging;
12
13
 
13
- import java.util.Arrays;
14
- import java.util.Collections;
15
- import java.util.List;
16
-
17
14
  import com.facebook.react.ReactPackage;
15
+ import com.facebook.react.bridge.JavaScriptModule;
18
16
  import com.facebook.react.bridge.NativeModule;
19
17
  import com.facebook.react.bridge.ReactApplicationContext;
20
18
  import com.facebook.react.uimanager.ViewManager;
21
- import com.facebook.react.bridge.JavaScriptModule;
19
+ import java.util.Arrays;
20
+ import java.util.Collections;
21
+ import java.util.List;
22
22
  public class RCTAEPMessagingPackage implements ReactPackage {
23
23
 
24
- @Override
25
- public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
26
- return Arrays.<NativeModule>asList(new RCTAEPMessagingModule(reactContext));
27
- }
24
+ @Override
25
+ public List<NativeModule>
26
+ createNativeModules(ReactApplicationContext reactContext) {
27
+ return Arrays.<NativeModule>asList(new RCTAEPMessagingModule(reactContext));
28
+ }
28
29
 
29
- // Deprecated from RN 0.47
30
- public List<Class<? extends JavaScriptModule>> createJSModules() {
31
- return Collections.emptyList();
32
- }
30
+ // Deprecated from RN 0.47
31
+ public List<Class<? extends JavaScriptModule>> createJSModules() {
32
+ return Collections.emptyList();
33
+ }
33
34
 
34
- @Override
35
- public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
36
- return Collections.emptyList();
37
- }
35
+ @Override
36
+ public List<ViewManager>
37
+ createViewManagers(ReactApplicationContext reactContext) {
38
+ return Collections.emptyList();
39
+ }
38
40
  }