@adobe/react-native-aepmessaging 6.0.3 → 6.0.5

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 (49) hide show
  1. package/RCTAEPMessaging.podspec +2 -22
  2. package/README.md +51 -46
  3. package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingModule.java +13 -7
  4. package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingUtil.java +207 -202
  5. package/dist/Messaging.js +1 -1
  6. package/dist/index.d.ts +7 -1
  7. package/dist/index.js +3 -3
  8. package/dist/index.js.map +1 -1
  9. package/dist/models/ContentCard.d.ts +46 -0
  10. package/dist/models/ContentCard.js +14 -0
  11. package/dist/models/ContentCard.js.map +1 -0
  12. package/dist/models/HTMLProposition.d.ts +8 -0
  13. package/dist/models/HTMLProposition.js +14 -0
  14. package/dist/models/HTMLProposition.js.map +1 -0
  15. package/dist/models/InAppMessage.d.ts +15 -0
  16. package/dist/models/InAppMessage.js +14 -0
  17. package/dist/models/InAppMessage.js.map +1 -0
  18. package/dist/models/JSONPropositionItem.d.ts +8 -0
  19. package/dist/models/JSONPropositionItem.js +14 -0
  20. package/dist/models/JSONPropositionItem.js.map +1 -0
  21. package/dist/models/Message.js.map +1 -1
  22. package/dist/models/MessagingEdgeEventType.js +0 -1
  23. package/dist/models/MessagingEdgeEventType.js.map +1 -1
  24. package/dist/models/MessagingProposition.d.ts +5 -5
  25. package/dist/models/MessagingProposition.js +2 -12
  26. package/dist/models/MessagingProposition.js.map +1 -1
  27. package/dist/models/MessagingPropositionItem.d.ts +5 -8
  28. package/dist/models/PersonalizationSchema.d.ts +9 -0
  29. package/dist/models/PersonalizationSchema.js +25 -0
  30. package/dist/models/PersonalizationSchema.js.map +1 -0
  31. package/dist/models/ScopeDetails.d.ts +13 -0
  32. package/dist/models/ScopeDetails.js +14 -0
  33. package/dist/models/ScopeDetails.js.map +1 -0
  34. package/ios/src/RCTAEPMessaging.swift +7 -3
  35. package/ios/src/RCTAEPMessagingDataBridge.swift +3 -20
  36. package/package.json +2 -2
  37. package/src/Messaging.ts +1 -1
  38. package/src/index.ts +14 -1
  39. package/src/models/ContentCard.ts +47 -0
  40. package/src/models/HTMLProposition.ts +21 -0
  41. package/src/models/InAppMessage.ts +28 -0
  42. package/src/models/JSONPropositionItem.ts +21 -0
  43. package/src/models/Message.ts +1 -1
  44. package/src/models/MessagingDelegate.ts +1 -1
  45. package/src/models/MessagingEdgeEventType.ts +8 -8
  46. package/src/models/MessagingProposition.ts +8 -19
  47. package/src/models/MessagingPropositionItem.ts +10 -8
  48. package/src/models/PersonalizationSchema.ts +21 -0
  49. package/src/models/ScopeDetails.ts +27 -0
@@ -15,26 +15,6 @@ Pod::Spec.new do |s|
15
15
  s.source_files = "ios/**/*.{h,m,mm,swift}"
16
16
  s.swift_version = '5.1'
17
17
 
18
- s.dependency "AEPMessaging", ">= 5.0.0", "< 6.0.0"
19
-
20
- if respond_to?(:install_modules_dependencies, true)
21
- install_modules_dependencies(s)
22
- else
23
- s.dependency "React-Core"
24
-
25
- # Don't install the dependencies when we run `pod install` in the old architecture.
26
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
27
- s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
28
- s.pod_target_xcconfig = {
29
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
30
- "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
31
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
32
- }
33
- s.dependency "React-Codegen"
34
- s.dependency "RCT-Folly"
35
- s.dependency "RCTRequired"
36
- s.dependency "RCTTypeSafety"
37
- s.dependency "ReactCommon/turbomodule/core"
38
- end
39
- end
18
+ s.dependency "React"
19
+ s.dependency "AEPMessaging", ">= 5.3.0", "< 6.0.0"
40
20
  end
package/README.md CHANGED
@@ -114,8 +114,8 @@ import {
114
114
  Messaging,
115
115
  MessagingDelegate,
116
116
  MessagingEdgeEventType,
117
- Message,
118
- } from "@adobe/react-native-aepmessaging";
117
+ Message
118
+ } from '@adobe/react-native-aepmessaging';
119
119
  ```
120
120
 
121
121
  ## API reference
@@ -134,7 +134,7 @@ extensionVersion(): Promise<string>
134
134
 
135
135
  ```javascript
136
136
  Messaging.extensionVersion().then((version) =>
137
- console.log("AdobeExperienceSDK: Messaging version: " + version)
137
+ console.log('AdobeExperienceSDK: Messaging version: ' + version)
138
138
  );
139
139
  ```
140
140
 
@@ -153,11 +153,11 @@ Handling push notifications must be done in native (Android/iOS) code for the Re
153
153
 
154
154
  The AEPMessaging extension's push messaging APIs must be called from the native Android/iOS project of React Native app.
155
155
 
156
- ###### [iOS API usage](https://github.com/adobe/aepsdk-messaging-ios/blob/main/Documentation/sources/usage.md)
156
+ ###### [iOS API usage](https://github.com/adobe/aepsdk-messaging-ios/blob/main/Documentation/sources/push-messaging/developer-documentation/api-usage.md)
157
157
 
158
158
  ##### [Android API usage](https://github.com/adobe/aepsdk-messaging-android/blob/main/Documentation/sources/api-usage.md)
159
159
 
160
- In Android, [MessagingPushPayload](https://github.com/adobe/aepsdk-messaging-android/blob/main/Documentation/sources/messaging-push-payload.md#messagingpushpayload-usage) can be used for getting the notification attributes like title, body, and action. These are useful for push notification creation.
160
+ In Android, [MessagingPushPayload](https://github.com/adobe/aepsdk-messaging-android/blob/main/Documentation/sources/push-notification/manual-handling-and-tracking.md) can be used for getting the notification attributes like title, body, and action. These are useful for push notification creation.
161
161
 
162
162
  ## In-app messages API reference
163
163
 
@@ -168,13 +168,13 @@ Initiates a network call to retrieve remote in-app message definitions.
168
168
  **Syntax**
169
169
 
170
170
  ```javascript
171
- refreshInAppMessages()
171
+ refreshInAppMessages();
172
172
  ```
173
173
 
174
174
  **Example**
175
175
 
176
176
  ```javascript
177
- Messaging.refreshInAppMessages()
177
+ Messaging.refreshInAppMessages();
178
178
  ```
179
179
 
180
180
  ### setMessagingDelegate
@@ -205,24 +205,20 @@ const messagingDelegate = {
205
205
 
206
206
  urlLoaded(url: string, message: Message) {
207
207
  // Action after message loads an URL
208
- },
208
+ }
209
209
  };
210
210
 
211
- Messaging.setMessagingDelegate(messagingDelegate)
211
+ Messaging.setMessagingDelegate(messagingDelegate);
212
212
  ```
213
213
 
214
-
215
-
216
214
  **Example**
217
215
 
218
216
  ```javascript
219
217
  const messagingDelegate = {
220
-
221
218
  shouldShowMessage(message: Message) {
222
- Messaging.saveMessage(message)
219
+ Messaging.saveMessage(message);
223
220
  return false;
224
- },
225
-
221
+ }
226
222
  };
227
223
  ```
228
224
 
@@ -239,12 +235,13 @@ updatePropositionsForSurfaces(surfaces: string[])
239
235
  **Example**
240
236
 
241
237
  ```javascript
242
- Messaging.updatePropositionsForSurfaces(["mobileapp://my-surface"])
238
+ Messaging.updatePropositionsForSurfaces(['mobileapp://my-surface']);
243
239
  ```
244
240
 
245
241
  ### getPropositionsForSurfaces
246
242
 
247
- Retrieves the previously fetched (and cached) feeds content from the SDK for the provided surfaces. If the feeds content for one or more surfaces isn't previously cached in the SDK, it will not be retrieved from Adobe Journey Optimizer via the Experience Edge network.
243
+ Retrieves the previously fetched (and cached) feeds content from the SDK for the provided surfaces. If the feeds content for one or more surfaces isn't previously cached in the SDK, it will not be retrieved from Adobe Journey Optimizer via the Experience Edge network. This can be used in order to retrieve code based experiences, content
244
+ cards and other proposition types.
248
245
 
249
246
  **Syntax**
250
247
 
@@ -255,8 +252,19 @@ getPropositionsForSurfaces(surfaces: string[])
255
252
  **Example**
256
253
 
257
254
  ```javascript
258
- const propositions = Messaging.getPropositionsForSurfaces(["mobileapp://my-surface"])
259
- console.log(propositions)
255
+ const propositions = Messaging.getPropositionsForSurfaces(['my-surface']);
256
+ console.log(propositions);
257
+ ```
258
+
259
+ Once propositions have been retrieved, their items will be typed to allow you to easily figure out what type they are using their schema property
260
+
261
+ ```javascript
262
+ for (let item in proposition.items) {
263
+ if (item.schema === PersonalizationSchema.CONTENT_CARD) {
264
+ // Proposition Item is a content card, and will be fully typed
265
+ console.log(item.data.content);
266
+ }
267
+ }
260
268
  ```
261
269
 
262
270
  ### getLatestMessage
@@ -266,14 +274,14 @@ Retrieves the most recently displayed message object
266
274
  **Syntax**
267
275
 
268
276
  ```javascript
269
- Messaging.getLatestMessage()
277
+ Messaging.getLatestMessage();
270
278
  ```
271
279
 
272
280
  **Example**
273
281
 
274
282
  ```javascript
275
- const message = Messaging.getLatestMessage()
276
- console.log(message.id)
283
+ const message = Messaging.getLatestMessage();
284
+ console.log(message.id);
277
285
  ```
278
286
 
279
287
  ### getCachedMessages
@@ -283,14 +291,14 @@ Retrieves a list of all messages that have been cached in-memory
283
291
  **Syntax**
284
292
 
285
293
  ```javascript
286
- Messaging.getCachedMessages()
294
+ Messaging.getCachedMessages();
287
295
  ```
288
296
 
289
297
  **Example**
290
298
 
291
299
  ```javascript
292
- const messages = Messaging.getCachedMessages()
293
- messages.forEach(message => message.clear())
300
+ const messages = Messaging.getCachedMessages();
301
+ messages.forEach((message) => message.clear());
294
302
  ```
295
303
 
296
304
  ### setMessageSettings
@@ -306,10 +314,9 @@ Messaging.setMessageSettings(shouldShowMessage: boolean, shouldSaveMessage: bool
306
314
  **Example**
307
315
 
308
316
  ```javascript
309
- Messaging.setMessageSettings(true, false)
317
+ Messaging.setMessageSettings(true, false);
310
318
  ```
311
319
 
312
-
313
320
  ## Handling In App Messages using Message Object
314
321
 
315
322
  The `Message` object passed to the `MessagingDelegate` contains the following functions to handle a message:
@@ -321,14 +328,14 @@ Signals to the `UIService` that the message should be shown.
321
328
  **Syntax**
322
329
 
323
330
  ```javascript
324
- show()
331
+ show();
325
332
  ```
326
333
 
327
334
  **Example**
328
335
 
329
336
  ```javascript
330
- var message: Message
331
- message.show()
337
+ var message: Message;
338
+ message.show();
332
339
  ```
333
340
 
334
341
  ### dismiss
@@ -344,8 +351,8 @@ dismiss(((suppressAutoTrack: ?boolean) = false))
344
351
  **Example**
345
352
 
346
353
  ```javascript
347
- var message: Message
348
- message.dismiss(true)
354
+ var message: Message;
355
+ message.dismiss(true);
349
356
  ```
350
357
 
351
358
  ### track
@@ -362,7 +369,7 @@ track(interaction: ?string, eventType: MessagingEdgeEventType)
362
369
 
363
370
  ```javascript
364
371
  var message: Message;
365
- message.track("sample text", MessagingEdgeEventType.IN_APP_DISMISS)
372
+ message.track('sample text', MessagingEdgeEventType.IN_APP_DISMISS);
366
373
  ```
367
374
 
368
375
  ### handleJavascriptMessage
@@ -379,7 +386,7 @@ handleJavascriptMessage(name: string) : Promise<?any>
379
386
 
380
387
  ```javascript
381
388
  var message: Message;
382
- message.handleJavascriptMessage("test").then((data) => {})
389
+ message.handleJavascriptMessage('test').then((data) => {});
383
390
  ```
384
391
 
385
392
  ### setAutoTrack
@@ -396,7 +403,7 @@ setAutoTrack(autoTrack: boolean)
396
403
 
397
404
  ```javascript
398
405
  var message: Message;
399
- message.setAutoTrack(true)
406
+ message.setAutoTrack(true);
400
407
  ```
401
408
 
402
409
  ### clear
@@ -406,14 +413,14 @@ Clears the reference to the in-memory cached `Message` object. This function mus
406
413
  **Syntax**
407
414
 
408
415
  ```javascript
409
- clear()
416
+ clear();
410
417
  ```
411
418
 
412
419
  **Example**
413
420
 
414
421
  ```javascript
415
- var message: Message
416
- message.clear()
422
+ var message: Message;
423
+ message.clear();
417
424
  ```
418
425
 
419
426
  ## Programmatically control the display of in-app messages
@@ -432,7 +439,7 @@ type MessagingDelegate = {
432
439
 
433
440
  urlLoaded(url: string, message: Message): void, // iOS Only
434
441
 
435
- onContentLoaded(message: Message): void, // Android Only
442
+ onContentLoaded(message: Message): void // Android Only
436
443
  };
437
444
  ```
438
445
 
@@ -458,9 +465,8 @@ const messagingDelegate = {
458
465
 
459
466
  onContentLoaded(message: Message) {
460
467
  // Action after message loads content
461
- },
468
+ }
462
469
  };
463
-
464
470
  ```
465
471
 
466
472
  ### Controlling when the message should be shown to the end user.
@@ -471,7 +477,7 @@ Below is an example of when the developer may choose to suppress an in-app messa
471
477
 
472
478
  ```javascript
473
479
  function shouldShowMessage(message: Message): boolean {
474
- if (someOtherWorkflowStatus == "inProgress") {
480
+ if (someOtherWorkflowStatus == 'inProgress') {
475
481
  return false;
476
482
  }
477
483
 
@@ -486,12 +492,12 @@ Continuing with the above example, the developer has stored the message that was
486
492
  var cachedMessage: Message;
487
493
 
488
494
  function otherWorkflowFinished() {
489
- anotherWorkflowStatus = "complete";
495
+ anotherWorkflowStatus = 'complete';
490
496
  cachedMessage.show();
491
497
  }
492
498
 
493
499
  function shouldShowMessage(message: Message): boolean {
494
- if (anotherWorkflowStatus === "inProgress") {
500
+ if (anotherWorkflowStatus === 'inProgress') {
495
501
  // store the current message for later use
496
502
  Messaging.saveMessage(message);
497
503
  cachedMessage = message;
@@ -506,9 +512,8 @@ function shouldShowMessage(message: Message): boolean {
506
512
 
507
513
  ```javascript
508
514
  function otherWorkflowFinished() {
509
- anotherWorkflowStatus = "complete";
515
+ anotherWorkflowStatus = 'complete';
510
516
  currentMessage.show();
511
517
  currentMessage.clearMessage();
512
518
  }
513
519
  ```
514
-
@@ -11,6 +11,8 @@
11
11
  */
12
12
  package com.adobe.marketing.mobile.reactnative.messaging;
13
13
 
14
+ import static com.adobe.marketing.mobile.reactnative.messaging.RCTAEPMessagingUtil.convertMessageToMap;
15
+
14
16
  import android.app.Activity;
15
17
 
16
18
  import androidx.annotation.NonNull;
@@ -84,7 +86,11 @@ public final class RCTAEPMessagingModule
84
86
 
85
87
  @ReactMethod
86
88
  public void getLatestMessage(final Promise promise) {
87
- promise.resolve(this.latestMessage);
89
+ if (this.latestMessage != null) {
90
+ promise.resolve(RCTAEPMessagingUtil.convertToReadableMap(convertMessageToMap(this.latestMessage)));
91
+ } else {
92
+ promise.resolve(null);
93
+ }
88
94
  }
89
95
 
90
96
  @ReactMethod
@@ -174,7 +180,7 @@ public final class RCTAEPMessagingModule
174
180
  Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
175
181
  if (message != null) {
176
182
  Map<String, String> data =
177
- RCTAEPMessagingUtil.convertMessageToMap(message);
183
+ convertMessageToMap(message);
178
184
  emitEvent("onShow", data);
179
185
  }
180
186
  }
@@ -185,7 +191,7 @@ public final class RCTAEPMessagingModule
185
191
  Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
186
192
  if (message != null) {
187
193
  Map<String, String> data =
188
- RCTAEPMessagingUtil.convertMessageToMap(message);
194
+ convertMessageToMap(message);
189
195
  emitEvent("onDismiss", data);
190
196
  }
191
197
  }
@@ -196,7 +202,7 @@ public final class RCTAEPMessagingModule
196
202
  Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
197
203
  if (message != null) {
198
204
  Map<String, String> data =
199
- RCTAEPMessagingUtil.convertMessageToMap(message);
205
+ convertMessageToMap(message);
200
206
  emitEvent("onHide", data);
201
207
  }
202
208
  }
@@ -207,7 +213,7 @@ public final class RCTAEPMessagingModule
207
213
  Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
208
214
  if (message != null) {
209
215
  Map<String, String> data =
210
- RCTAEPMessagingUtil.convertMessageToMap(message);
216
+ convertMessageToMap(message);
211
217
  emitEvent("shouldShowMessage", data);
212
218
  // Latch stops the thread until the shouldShowMessage value is received
213
219
  // from the JS side on thread dedicated to run JS code. The function
@@ -234,7 +240,7 @@ public final class RCTAEPMessagingModule
234
240
  Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
235
241
  if (message != null) {
236
242
  Map<String, String> data =
237
- RCTAEPMessagingUtil.convertMessageToMap(message);
243
+ convertMessageToMap(message);
238
244
  emitEvent("onContentLoaded", data);
239
245
  }
240
246
  }
@@ -263,4 +269,4 @@ public final class RCTAEPMessagingModule
263
269
  .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
264
270
  .emit(name, eventData);
265
271
  }
266
- }
272
+ }