@adobe/react-native-aepmessaging 5.0.0 → 5.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/.babelrc +1 -1
  2. package/RCTAEPMessaging.podspec +25 -7
  3. package/README.md +109 -9
  4. package/android/build.gradle +87 -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 +267 -200
  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 +131 -0
  11. package/dist/Messaging.d.ts +62 -0
  12. package/dist/Messaging.js +112 -0
  13. package/dist/Messaging.js.map +1 -0
  14. package/{js → dist}/index.js +1 -1
  15. package/dist/index.js.map +1 -0
  16. package/dist/models/Message.d.ts +46 -0
  17. package/dist/models/Message.js +73 -0
  18. package/dist/models/Message.js.map +1 -0
  19. package/dist/models/MessagingDelegate.d.ts +30 -0
  20. package/{js → dist}/models/MessagingDelegate.js +1 -1
  21. package/dist/models/MessagingDelegate.js.map +1 -0
  22. package/{js → dist}/models/MessagingEdgeEventType.js +1 -1
  23. package/dist/models/MessagingEdgeEventType.js.map +1 -0
  24. package/dist/models/MessagingProposition.d.ts +8 -0
  25. package/dist/models/MessagingProposition.js +24 -0
  26. package/dist/models/MessagingProposition.js.map +1 -0
  27. package/dist/models/MessagingPropositionItem.d.ts +6 -0
  28. package/dist/models/MessagingPropositionItem.js +23 -0
  29. package/dist/models/MessagingPropositionItem.js.map +1 -0
  30. package/ios/src/RCTAEPMessaging-Bridging-Header.h +15 -0
  31. package/ios/src/RCTAEPMessaging.mm +50 -0
  32. package/ios/src/RCTAEPMessaging.swift +283 -0
  33. package/ios/src/RCTAEPMessagingConstants.swift +22 -0
  34. package/ios/src/RCTAEPMessagingDataBridge.swift +41 -0
  35. package/package.json +3 -3
  36. package/src/Messaging.ts +147 -0
  37. package/{ts → src}/index.ts +1 -1
  38. package/src/models/Message.ts +84 -0
  39. package/src/models/MessagingDelegate.ts +47 -0
  40. package/{ts → src}/models/MessagingEdgeEventType.ts +1 -1
  41. package/src/models/MessagingProposition.ts +32 -0
  42. package/src/models/MessagingPropositionItem.ts +23 -0
  43. package/tsconfig.json +2 -2
  44. package/ios/RCTAEPMessaging.xcodeproj/project.pbxproj +0 -304
  45. package/ios/src/RCTAEPMessaging.h +0 -20
  46. package/ios/src/RCTAEPMessaging.m +0 -196
  47. package/js/Messaging.d.ts +0 -32
  48. package/js/Messaging.js +0 -80
  49. package/js/Messaging.js.map +0 -1
  50. package/js/index.js.map +0 -1
  51. package/js/models/Message.d.ts +0 -43
  52. package/js/models/Message.js +0 -80
  53. package/js/models/Message.js.map +0 -1
  54. package/js/models/MessagingDelegate.d.ts +0 -25
  55. package/js/models/MessagingDelegate.js.map +0 -1
  56. package/js/models/MessagingEdgeEventType.js.map +0 -1
  57. package/ts/Messaging.ts +0 -99
  58. package/ts/models/Message.ts +0 -82
  59. package/ts/models/MessagingDelegate.ts +0 -41
  60. /package/{js → dist}/index.d.ts +0 -0
  61. /package/{js → dist}/models/MessagingEdgeEventType.d.ts +0 -0
@@ -0,0 +1,131 @@
1
+ /*
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.
11
+ */
12
+
13
+ package com.adobe.marketing.mobile.reactnative.messaging;
14
+
15
+ import android.app.Activity;
16
+ import com.adobe.marketing.mobile.Message;
17
+ import com.adobe.marketing.mobile.MessagingEdgeEventType;
18
+ import com.adobe.marketing.mobile.messaging.MessagingProposition;
19
+ import com.adobe.marketing.mobile.messaging.MessagingPropositionItem;
20
+ import com.adobe.marketing.mobile.messaging.Surface;
21
+ import com.facebook.react.bridge.ReadableArray;
22
+ import com.facebook.react.bridge.ReadableMap;
23
+ import com.facebook.react.bridge.WritableArray;
24
+ import com.facebook.react.bridge.WritableNativeArray;
25
+ import java.util.ArrayList;
26
+ import java.util.Collection;
27
+ import java.util.HashMap;
28
+ import java.util.Iterator;
29
+ import java.util.List;
30
+ import java.util.ListIterator;
31
+ import java.util.Map;
32
+
33
+ /**
34
+ * Utility class for converting data models to {@link
35
+ * com.facebook.react.bridge.WritableMap}
36
+ */
37
+
38
+ class RCTAEPMessagingUtil {
39
+
40
+ private static final String TAG = "RCTAEPMessaging";
41
+
42
+ private RCTAEPMessagingUtil() {}
43
+
44
+ // From React Native
45
+ static MessagingEdgeEventType getEventType(final int eventType) {
46
+ switch (eventType) {
47
+ case 0:
48
+ return MessagingEdgeEventType.IN_APP_DISMISS;
49
+ case 1:
50
+ return MessagingEdgeEventType.IN_APP_INTERACT;
51
+ case 2:
52
+ return MessagingEdgeEventType.IN_APP_TRIGGER;
53
+ case 3:
54
+ return MessagingEdgeEventType.IN_APP_DISPLAY;
55
+ case 4:
56
+ return MessagingEdgeEventType.PUSH_APPLICATION_OPENED;
57
+ case 5:
58
+ return MessagingEdgeEventType.PUSH_CUSTOM_ACTION;
59
+ default:
60
+ return null;
61
+ }
62
+ }
63
+
64
+ static List<Surface> convertSurfaces(final ReadableArray rawSurfaces) {
65
+ List<Surface> surfaces = new ArrayList<>();
66
+
67
+ for (int i = 0; i < rawSurfaces.size(); i++) {
68
+ surfaces.add(new Surface(rawSurfaces.getString(i)));
69
+ }
70
+
71
+ return surfaces;
72
+ }
73
+
74
+ // To React Native
75
+
76
+ static Map convertMessageToMap(final Message message) {
77
+ Map data = new HashMap<>();
78
+ data.put("id", message.getId());
79
+ data.put("autoTrack", message.getAutoTrack());
80
+ return data;
81
+ }
82
+
83
+ static ReadableArray convertMessagesToJS(final Collection<Message> messages) {
84
+ WritableArray result = new WritableNativeArray();
85
+
86
+ for (Iterator<Message> iterator = messages.iterator();
87
+ iterator.hasNext();) {
88
+ result.pushMap((ReadableMap)convertMessageToMap(iterator.next()));
89
+ }
90
+
91
+ return result;
92
+ }
93
+
94
+ static Map
95
+ convertMessagingPropositionToJS(final MessagingProposition proposition) {
96
+ Map data = new HashMap<>();
97
+ ArrayList<Map> propositionItems = new ArrayList();
98
+ ListIterator<MessagingPropositionItem> it =
99
+ proposition.getItems().listIterator();
100
+
101
+ while (it.hasNext()) {
102
+ Map item = new HashMap<>();
103
+ item.put("uniqueId", it.next().getUniqueId());
104
+ item.put("uniqueId", it.next().getContent());
105
+ item.put("uniqueId", it.next().getSchema());
106
+
107
+ propositionItems.add(item);
108
+ }
109
+
110
+ data.put("scope", proposition.getScope());
111
+ data.put("uniqueId", proposition.getUniqueId());
112
+ data.put("items", propositionItems);
113
+
114
+ return data;
115
+ }
116
+
117
+ static Map convertSurfacePropositions(
118
+ final Map<Surface, List<MessagingProposition>> propositionMap,
119
+ String packageName) {
120
+ Map data = new HashMap<>();
121
+
122
+ for (Map.Entry<Surface, List<MessagingProposition>> entry :
123
+ propositionMap.entrySet()) {
124
+ data.put(entry.getKey().getUri().replace(
125
+ "mobileapp://" + packageName + "/", ""),
126
+ entry.getValue());
127
+ }
128
+
129
+ return data;
130
+ }
131
+ }
@@ -0,0 +1,62 @@
1
+ import Message from './models/Message';
2
+ import { MessagingDelegate } from './models/MessagingDelegate';
3
+ import { MessagingProposition } from './models/MessagingProposition';
4
+ export interface NativeMessagingModule {
5
+ extensionVersion: () => Promise<string>;
6
+ getCachedMessages: () => Message[];
7
+ getLatestMessage: () => Message;
8
+ getPropositionsForSurfaces: (surfaces: string[]) => Record<string, MessagingProposition[]>;
9
+ refreshInAppMessages: () => void;
10
+ setMessagingDelegate: (delegate?: MessagingDelegate) => void;
11
+ setMessageSettings: (shouldShowMessage: boolean, shouldSaveMessage: boolean) => void;
12
+ updatePropositionsForSurfaces: (surfaces: string[]) => void;
13
+ }
14
+ declare class Messaging {
15
+ /**
16
+ * Returns the version of the AEPMessaging extension
17
+ * @returns {string} Promise a promise that resolves with the extension version
18
+ */
19
+ static extensionVersion(): Promise<string>;
20
+ /**
21
+ * Initiates a network call to retrieve remote In-App Message definitions.
22
+ */
23
+ static refreshInAppMessages(): void;
24
+ /**
25
+ * Retrieves the list of messages which have been cached using the `shouldSaveMessage`
26
+ * method of the messaging delegate.
27
+ * Note: Messages should be cached before trying to use any of the methods on the message class
28
+ * @returns An array of messages that have been cached
29
+ */
30
+ static getCachedMessages(): Promise<Message[]>;
31
+ /**
32
+ * Retrieves the last message that has been shown in the UI
33
+ * @returns The latest message to have been displayed
34
+ */
35
+ static getLatestMessage(): Promise<Message>;
36
+ /**
37
+ * Retrieves the previously fetched (and cached) feeds content from the SDK for the provided surfaces.
38
+ * 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.
39
+ * @param surfaces A list of surfaces to fetch
40
+ * @returns A record of surface names with their corresponding propositions
41
+ */
42
+ static getPropositionsForSurfaces(surfaces: string[]): Promise<Record<string, MessagingProposition[]>>;
43
+ /**
44
+ * Function to set the UI Message delegate to listen the Message lifecycle events.
45
+ * @returns A function to unsubscribe from all event listeners
46
+ */
47
+ static setMessagingDelegate(delegate: MessagingDelegate): () => void;
48
+ /**
49
+ * Sets global settings for messages being shown and cached
50
+ * Note: This method is also used by MessagingDelegate.shouldShowMessage,
51
+ * which allows finer-grained control over setting these settings
52
+ * @param shouldShowMessage Whether or not a message should be displayed
53
+ * @param shouldSaveMessage Whether or not a message should be cached
54
+ */
55
+ static setMessageSettings(shouldShowMessage: boolean, shouldSaveMessage: boolean): void;
56
+ /**
57
+ * Dispatches an event to fetch propositions for the provided surfaces from remote.
58
+ * @param surfaces A list of surface names to update
59
+ */
60
+ static updatePropositionsForSurfaces(surfaces: string[]): void;
61
+ }
62
+ export default Messaging;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2023 Adobe. All rights reserved.
4
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License. You may obtain a copy
6
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under
9
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
10
+ OF ANY KIND, either express or implied. See the License for the specific language
11
+ governing permissions and limitations under the License.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const tslib_1 = require("tslib");
15
+ const react_native_1 = require("react-native");
16
+ const Message_1 = tslib_1.__importDefault(require("./models/Message"));
17
+ const RCTAEPMessaging = react_native_1.NativeModules.AEPMessaging;
18
+ var messagingDelegate;
19
+ class Messaging {
20
+ /**
21
+ * Returns the version of the AEPMessaging extension
22
+ * @returns {string} Promise a promise that resolves with the extension version
23
+ */
24
+ static extensionVersion() {
25
+ return Promise.resolve(RCTAEPMessaging.extensionVersion());
26
+ }
27
+ /**
28
+ * Initiates a network call to retrieve remote In-App Message definitions.
29
+ */
30
+ static refreshInAppMessages() {
31
+ RCTAEPMessaging.refreshInAppMessages();
32
+ }
33
+ /**
34
+ * Retrieves the list of messages which have been cached using the `shouldSaveMessage`
35
+ * method of the messaging delegate.
36
+ * Note: Messages should be cached before trying to use any of the methods on the message class
37
+ * @returns An array of messages that have been cached
38
+ */
39
+ static getCachedMessages() {
40
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
41
+ const messages = yield RCTAEPMessaging.getCachedMessages();
42
+ return messages.map(msg => new Message_1.default(msg));
43
+ });
44
+ }
45
+ /**
46
+ * Retrieves the last message that has been shown in the UI
47
+ * @returns The latest message to have been displayed
48
+ */
49
+ static getLatestMessage() {
50
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
51
+ const message = yield RCTAEPMessaging.getLatestMessage();
52
+ return message ? new Message_1.default(message) : undefined;
53
+ });
54
+ }
55
+ /**
56
+ * Retrieves the previously fetched (and cached) feeds content from the SDK for the provided surfaces.
57
+ * 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.
58
+ * @param surfaces A list of surfaces to fetch
59
+ * @returns A record of surface names with their corresponding propositions
60
+ */
61
+ static getPropositionsForSurfaces(surfaces) {
62
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
63
+ return yield RCTAEPMessaging.getPropositionsForSurfaces(surfaces);
64
+ });
65
+ }
66
+ /**
67
+ * Function to set the UI Message delegate to listen the Message lifecycle events.
68
+ * @returns A function to unsubscribe from all event listeners
69
+ */
70
+ static setMessagingDelegate(delegate) {
71
+ messagingDelegate = delegate;
72
+ const eventEmitter = new react_native_1.NativeEventEmitter(RCTAEPMessaging);
73
+ eventEmitter.addListener('onShow', (message) => { var _a; return (_a = messagingDelegate === null || messagingDelegate === void 0 ? void 0 : messagingDelegate.onShow) === null || _a === void 0 ? void 0 : _a.call(messagingDelegate, message); });
74
+ eventEmitter.addListener('onDismiss', (message) => {
75
+ var _a;
76
+ (_a = messagingDelegate === null || messagingDelegate === void 0 ? void 0 : messagingDelegate.onDismiss) === null || _a === void 0 ? void 0 : _a.call(messagingDelegate, message);
77
+ });
78
+ eventEmitter.addListener('shouldShowMessage', (message) => {
79
+ var _a, _b, _c, _d;
80
+ const shouldShowMessage = (_b = (_a = messagingDelegate === null || messagingDelegate === void 0 ? void 0 : messagingDelegate.shouldShowMessage) === null || _a === void 0 ? void 0 : _a.call(messagingDelegate, message)) !== null && _b !== void 0 ? _b : true;
81
+ const shouldSaveMessage = (_d = (_c = messagingDelegate === null || messagingDelegate === void 0 ? void 0 : messagingDelegate.shouldSaveMessage) === null || _c === void 0 ? void 0 : _c.call(messagingDelegate, message)) !== null && _d !== void 0 ? _d : false;
82
+ RCTAEPMessaging.setMessageSettings(shouldShowMessage, shouldSaveMessage);
83
+ });
84
+ eventEmitter.addListener('urlLoaded', (event) => { var _a; return (_a = messagingDelegate === null || messagingDelegate === void 0 ? void 0 : messagingDelegate.urlLoaded) === null || _a === void 0 ? void 0 : _a.call(messagingDelegate, event.url, event.message); });
85
+ RCTAEPMessaging.setMessagingDelegate();
86
+ return () => {
87
+ eventEmitter.removeAllListeners('onDismiss');
88
+ eventEmitter.removeAllListeners('onShow');
89
+ eventEmitter.removeAllListeners('shouldShowMessage');
90
+ eventEmitter.removeAllListeners('urlLoaded');
91
+ };
92
+ }
93
+ /**
94
+ * Sets global settings for messages being shown and cached
95
+ * Note: This method is also used by MessagingDelegate.shouldShowMessage,
96
+ * which allows finer-grained control over setting these settings
97
+ * @param shouldShowMessage Whether or not a message should be displayed
98
+ * @param shouldSaveMessage Whether or not a message should be cached
99
+ */
100
+ static setMessageSettings(shouldShowMessage, shouldSaveMessage) {
101
+ RCTAEPMessaging.setMessageSettings(shouldShowMessage, shouldSaveMessage);
102
+ }
103
+ /**
104
+ * Dispatches an event to fetch propositions for the provided surfaces from remote.
105
+ * @param surfaces A list of surface names to update
106
+ */
107
+ static updatePropositionsForSurfaces(surfaces) {
108
+ RCTAEPMessaging.updatePropositionsForSurfaces(surfaces);
109
+ }
110
+ }
111
+ exports.default = Messaging;
112
+ //# sourceMappingURL=Messaging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Messaging.js","sourceRoot":"","sources":["../src/Messaging.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;AAEF,+CAA+E;AAC/E,uEAAuC;AAoBvC,MAAM,eAAe,GACnB,4BAAa,CAAC,YAAY,CAAC;AAG7B,IAAI,iBAAoC,CAAC;AAEzC,MAAM,SAAS;IACb;;;OAGG;IACH,MAAM,CAAC,gBAAgB;QACrB,OAAO,OAAO,CAAC,OAAO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CAAC;CACF;AAED,kBAAe,SAAS,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright 2022 Adobe. All rights reserved.
3
+ Copyright 2023 Adobe. All rights reserved.
4
4
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License. You may obtain a copy
6
6
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;;AAEF,oEAAoC;AAK3B,oBALF,mBAAS,CAKE;AAJlB,uEAAuC;AAInB,kBAJb,iBAAO,CAIa;AAF3B,qGAAqE;AAErB,iCAFzC,gCAAsB,CAEyC"}
@@ -0,0 +1,46 @@
1
+ declare class Message {
2
+ id: string;
3
+ autoTrack: boolean;
4
+ constructor({ id, autoTrack }: {
5
+ id: string;
6
+ autoTrack: boolean;
7
+ });
8
+ /**
9
+ * Update the value of property "autoTrack"
10
+ * This function works only for the Message objects that were saved by calling "Messaging.saveMessage"
11
+ * @param {boolean} autoTrack: New value of property autoTrack.
12
+ */
13
+ setAutoTrack(autoTrack: boolean): void;
14
+ /**
15
+ * Signals to the UIServices that the message should be shown.
16
+ * If autoTrack is true, calling this method will result in an "inapp.display" Edge Event being dispatched.
17
+ */
18
+ show(): void;
19
+ /**
20
+ * Signals to the UIServices that the message should be dismissed.
21
+ * If `autoTrack` is true, calling this method will result in an "inapp.dismiss" Edge Event being dispatched.
22
+ * @param {boolean?} suppressAutoTrack: if set to true, the inapp.dismiss Edge Event will not be sent regardless
23
+ * of the autoTrack setting.
24
+ */
25
+ dismiss(suppressAutoTrack?: boolean): void;
26
+ /**
27
+ * Generates an Edge Event for the provided interaction and eventType.
28
+ * @param {string?} interaction: a custom String value to be recorded in the interaction
29
+ * @param {MessagingEdgeEventType} eventType: the MessagingEdgeEventType to be used for the ensuing Edge Event
30
+ */
31
+ track(interaction: string, eventType: number): void;
32
+ /**
33
+ * Adds a handler for Javascript messages sent from the message's webview.
34
+ * The parameter passed to `handler` will contain the body of the message passed from the webview's Javascript.
35
+ * @param {string} name: the name of the message that should be handled by `handler`
36
+ * @return {Promise<any?>}: the Promise to be resolved with the body of the message passed by the Javascript message in the WebView
37
+ */
38
+ handleJavascriptMessage(name: string): Promise<any>;
39
+ /**
40
+ * Clears the cached reference to the Message object.
41
+ * This function must be called if Message was saved by calling "MessagingDelegate.shouldSaveMessage" but no longer needed.
42
+ * Failure to call this function leads to memory leaks.
43
+ */
44
+ clear(): void;
45
+ }
46
+ export default Message;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2023 Adobe. All rights reserved.
4
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License. You may obtain a copy
6
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under
9
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
10
+ OF ANY KIND, either express or implied. See the License for the specific language
11
+ governing permissions and limitations under the License.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const react_native_1 = require("react-native");
15
+ const RCTAEPMessaging = react_native_1.NativeModules.AEPMessaging;
16
+ class Message {
17
+ constructor({ id, autoTrack = false }) {
18
+ this.id = id;
19
+ this.autoTrack = autoTrack;
20
+ }
21
+ /**
22
+ * Update the value of property "autoTrack"
23
+ * This function works only for the Message objects that were saved by calling "Messaging.saveMessage"
24
+ * @param {boolean} autoTrack: New value of property autoTrack.
25
+ */
26
+ setAutoTrack(autoTrack) {
27
+ this.autoTrack = autoTrack;
28
+ RCTAEPMessaging.setAutoTrack(this.id, autoTrack);
29
+ }
30
+ /**
31
+ * Signals to the UIServices that the message should be shown.
32
+ * If autoTrack is true, calling this method will result in an "inapp.display" Edge Event being dispatched.
33
+ */
34
+ show() {
35
+ RCTAEPMessaging.show(this.id);
36
+ }
37
+ /**
38
+ * Signals to the UIServices that the message should be dismissed.
39
+ * If `autoTrack` is true, calling this method will result in an "inapp.dismiss" Edge Event being dispatched.
40
+ * @param {boolean?} suppressAutoTrack: if set to true, the inapp.dismiss Edge Event will not be sent regardless
41
+ * of the autoTrack setting.
42
+ */
43
+ dismiss(suppressAutoTrack) {
44
+ RCTAEPMessaging.dismiss(this.id, suppressAutoTrack ? true : false);
45
+ }
46
+ /**
47
+ * Generates an Edge Event for the provided interaction and eventType.
48
+ * @param {string?} interaction: a custom String value to be recorded in the interaction
49
+ * @param {MessagingEdgeEventType} eventType: the MessagingEdgeEventType to be used for the ensuing Edge Event
50
+ */
51
+ track(interaction, eventType) {
52
+ RCTAEPMessaging.track(this.id, interaction, eventType);
53
+ }
54
+ /**
55
+ * Adds a handler for Javascript messages sent from the message's webview.
56
+ * The parameter passed to `handler` will contain the body of the message passed from the webview's Javascript.
57
+ * @param {string} name: the name of the message that should be handled by `handler`
58
+ * @return {Promise<any?>}: the Promise to be resolved with the body of the message passed by the Javascript message in the WebView
59
+ */
60
+ handleJavascriptMessage(name) {
61
+ return Promise.resolve(RCTAEPMessaging.handleJavascriptMessage(this.id, name));
62
+ }
63
+ /**
64
+ * Clears the cached reference to the Message object.
65
+ * This function must be called if Message was saved by calling "MessagingDelegate.shouldSaveMessage" but no longer needed.
66
+ * Failure to call this function leads to memory leaks.
67
+ */
68
+ clear() {
69
+ RCTAEPMessaging.clear(this.id);
70
+ }
71
+ }
72
+ exports.default = Message;
73
+ //# sourceMappingURL=Message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Message.js","sourceRoot":"","sources":["../../src/models/Message.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;AAEF,+CAA6C;AAC7C,MAAM,eAAe,GAAG,4BAAa,CAAC,YAAY,CAAC;AAEnD,MAAM,OAAO;IAIX,YAAY,EAAC,EAAE,EAAE,SAAS,GAAG,KAAK,EAAmC;QACnE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,SAAkB;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC;IAED;;;OAGG;IACH,IAAI;QACF,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,iBAA2B;QACjC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAmB,EAAE,SAAiB;QAC1C,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACH,uBAAuB,CAAC,IAAY;QAClC,OAAO,OAAO,CAAC,OAAO,CACpB,eAAe,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CACvD,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;CACF;AAED,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,30 @@
1
+ import Message from './Message';
2
+ export interface MessagingDelegate {
3
+ /**
4
+ * Invoked when the any message is displayed
5
+ * @param {Message} message: Message that is being displayed.
6
+ */
7
+ onShow?(message: Message): void;
8
+ /**
9
+ * Invoked when any message is dismissed
10
+ * @param {Message} message: Message that is being dismissed
11
+ */
12
+ onDismiss?(message: Message): void;
13
+ /**
14
+ * Used to determine whether a message should be cached, so it can be used later. Return true if the message should be cached.
15
+ * Note: Message must be cached in order to call any of the functions of the message object
16
+ */
17
+ shouldSaveMessage?(message: Message): boolean;
18
+ /**
19
+ * Used to find whether messages should be shown or not
20
+ * @param {Message} message: Message that is about to get displayed
21
+ * @returns {boolean}: true if the message should be shown else false
22
+ */
23
+ shouldShowMessage?(message: Message): boolean;
24
+ /**
25
+ * Called when message loads a URL
26
+ * @param {string} url: the URL being loaded by the message
27
+ * @param {Message} message: the Message loading a URL
28
+ */
29
+ urlLoaded?(url: string, message: Message): void;
30
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright 2022 Adobe. All rights reserved.
3
+ Copyright 2023 Adobe. All rights reserved.
4
4
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License. You may obtain a copy
6
6
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessagingDelegate.js","sourceRoot":"","sources":["../../src/models/MessagingDelegate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright 2022 Adobe. All rights reserved.
3
+ Copyright 2023 Adobe. All rights reserved.
4
4
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License. You may obtain a copy
6
6
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessagingEdgeEventType.js","sourceRoot":"","sources":["../../src/models/MessagingEdgeEventType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;AAEF,IAAK,sBAOJ;AAPD,WAAK,sBAAsB;IACvB,uFAAkB,CAAA;IAClB,yFAAmB,CAAA;IACnB,uFAAkB,CAAA;IAClB,uFAAkB,CAAA;IAClB,yGAA2B,CAAA;IAC3B,+FAAsB,CAAA;AAC1B,CAAC,EAPI,sBAAsB,KAAtB,sBAAsB,QAO1B;AAAA,CAAC;AAEF,kBAAe,sBAAsB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { MessagingPropositionItem } from './MessagingPropositionItem';
2
+ export declare class MessagingProposition {
3
+ items: MessagingPropositionItem[];
4
+ uniqueId: string;
5
+ scope: string;
6
+ scopeDetails: Record<string, any>;
7
+ constructor(uniqueId: string, scope: string, scopeDetails: Record<string, any>, items: MessagingPropositionItem[]);
8
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessagingProposition = void 0;
4
+ /*
5
+ Copyright 2023 Adobe. All rights reserved.
6
+ This file is licensed to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
10
+ or agreed to in writing, software distributed under the License is
11
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
12
+ ANY KIND, either express or implied. See the License for the specific
13
+ language governing permissions and limitations under the License.
14
+ */
15
+ class MessagingProposition {
16
+ constructor(uniqueId, scope, scopeDetails, items) {
17
+ this.uniqueId = uniqueId;
18
+ this.scope = scope;
19
+ this.scopeDetails = scopeDetails;
20
+ this.items = items;
21
+ }
22
+ }
23
+ exports.MessagingProposition = MessagingProposition;
24
+ //# sourceMappingURL=MessagingProposition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessagingProposition.js","sourceRoot":"","sources":["../../src/models/MessagingProposition.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;EAUE;AAEF,MAAa,oBAAoB;IAM/B,YACE,QAAgB,EAChB,KAAa,EACb,YAAiC,EACjC,KAAiC;QAEjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAjBD,oDAiBC"}
@@ -0,0 +1,6 @@
1
+ export declare class MessagingPropositionItem {
2
+ content: string;
3
+ schema: string;
4
+ uniqueId: string;
5
+ constructor(uniqueId: string, schema: string, content: string);
6
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2023 Adobe. All rights reserved.
4
+ This file is licensed to you under the Apache License, Version 2.0 (the
5
+ "License"); you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
8
+ or agreed to in writing, software distributed under the License is
9
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
10
+ ANY KIND, either express or implied. See the License for the specific
11
+ language governing permissions and limitations under the License.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.MessagingPropositionItem = void 0;
15
+ class MessagingPropositionItem {
16
+ constructor(uniqueId, schema, content) {
17
+ this.uniqueId = uniqueId;
18
+ this.schema = schema;
19
+ this.content = content;
20
+ }
21
+ }
22
+ exports.MessagingPropositionItem = MessagingPropositionItem;
23
+ //# sourceMappingURL=MessagingPropositionItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessagingPropositionItem.js","sourceRoot":"","sources":["../../src/models/MessagingPropositionItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;AAEF,MAAa,wBAAwB;IAKnC,YAAY,QAAgB,EAAE,MAAc,EAAE,OAAe;QAC3D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAVD,4DAUC"}
@@ -0,0 +1,15 @@
1
+ /*
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.
11
+ */
12
+
13
+ #import <React/RCTBridgeModule.h>
14
+ #import <React/RCTEventEmitter.h>
15
+ #import <React/RCTViewManager.h>
@@ -0,0 +1,50 @@
1
+ /*
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.
11
+ */
12
+
13
+ #import <React/RCTBridgeModule.h>
14
+ #import <React/RCTEventEmitter.h>
15
+
16
+ @interface RCT_EXTERN_MODULE (RCTAEPMessaging, RCTEventEmitter)
17
+
18
+ RCT_EXTERN_METHOD(supportedEvents)
19
+
20
+ RCT_EXTERN_METHOD(extensionVersion
21
+ : (RCTPromiseResolveBlock)resolve rejecter
22
+ : (RCTPromiseRejectBlock)reject);
23
+
24
+ RCT_EXTERN_METHOD(getCachedMessages
25
+ : (RCTPromiseResolveBlock)resolve withRejecter
26
+ : (RCTPromiseRejectBlock)reject)
27
+
28
+ RCT_EXTERN_METHOD(getLatestMessage
29
+ : (RCTPromiseResolveBlock)resolve withRejecter
30
+ : (RCTPromiseRejectBlock)reject)
31
+
32
+ RCT_EXTERN_METHOD(getPropositionsForSurfaces
33
+ : (NSArray<NSString *> *)surfaces withResolver
34
+ : (RCTPromiseResolveBlock)resolve withRejecter
35
+ : (RCTPromiseRejectBlock)reject);
36
+
37
+ RCT_EXTERN_METHOD(refreshInAppMessages);
38
+
39
+ RCT_EXTERN_METHOD(setMessagingDelegate);
40
+
41
+ RCT_EXTERN_METHOD(setMessageSettings
42
+ : (BOOL) shouldShowMessage withShouldSaveMessage
43
+ : (BOOL)shouldSaveMessage);
44
+
45
+ RCT_EXTERN_METHOD(updatePropositionsForSurfaces
46
+ : (NSArray<NSString *> *)surfaces withResolver
47
+ : (RCTPromiseResolveBlock)resolve withRejecter
48
+ : (RCTPromiseRejectBlock)reject);
49
+
50
+ @end