@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
package/js/Messaging.js DELETED
@@ -1,80 +0,0 @@
1
- "use strict";
2
- /*
3
- Copyright 2022 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
- var savedMessageId = null;
20
- const Messaging = {
21
- /**
22
- * Returns the version of the AEPMessaging extension
23
- * @returns {string} Promise a promise that resolves with the extension version
24
- */
25
- extensionVersion() {
26
- return Promise.resolve(RCTAEPMessaging.extensionVersion());
27
- },
28
- /**
29
- * Initiates a network call to retrieve remote In-App Message definitions.
30
- */
31
- refreshInAppMessages() {
32
- RCTAEPMessaging.refreshInAppMessages();
33
- },
34
- /**
35
- * Function to set the UI Message delegate to listen the Message lifecycle events.
36
- */
37
- setMessagingDelegate(delegate) {
38
- messagingDelegate = delegate;
39
- RCTAEPMessaging.setMessagingDelegate();
40
- const eventEmitter = new react_native_1.NativeEventEmitter(RCTAEPMessaging);
41
- eventEmitter.addListener('onShow', (event) => {
42
- if (messagingDelegate) {
43
- const message = new Message_1.default(event.id, event.autoTrack === "true" ? true : false);
44
- messagingDelegate.onShow(message);
45
- }
46
- });
47
- eventEmitter.addListener('onDismiss', (event) => {
48
- if (messagingDelegate) {
49
- const message = new Message_1.default(event.id, event.autoTrack === "true" ? true : false);
50
- messagingDelegate.onDismiss(message);
51
- }
52
- });
53
- eventEmitter.addListener('shouldShowMessage', (event) => {
54
- if (messagingDelegate) {
55
- const message = new Message_1.default(event.id, event.autoTrack === "true" ? true : false);
56
- const shouldShowMessage = messagingDelegate.shouldShowMessage(message);
57
- RCTAEPMessaging.shouldShowMessage(shouldShowMessage, savedMessageId ? true : false);
58
- savedMessageId = null;
59
- }
60
- });
61
- eventEmitter.addListener('urlLoaded', (event) => {
62
- if (messagingDelegate) {
63
- const url = event.url;
64
- const message = new Message_1.default(event.id, event.autoTrack === "true" ? true : false);
65
- messagingDelegate.urlLoaded(url, message);
66
- }
67
- });
68
- },
69
- /**
70
- * Cache the Message object in-memory to use later.
71
- * If there is a requirement to call the Message functions like show, dismiss etc. The Message object should be saved first before calling it's functions.
72
- * If the Message is saved using this API then it is responsibility of App to free it after using.
73
- * To remove the Message from memory call clearMessage function of Message. Failure to call clearMessage will cause the Memory leak of Message object.
74
- */
75
- saveMessage(message) {
76
- savedMessageId = message.id;
77
- },
78
- };
79
- exports.default = Messaging;
80
- //# sourceMappingURL=Messaging.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Messaging.js","sourceRoot":"","sources":["../ts/Messaging.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;AAEF,+CAA+E;AAC/E,uEAAuC;AAWvC,MAAM,eAAe,GAA8B,4BAAa,CAAC,YAAY,CAAC;AAK9E,IAAI,iBAAoC,CAAC;AACzC,IAAI,cAAc,GAAW,IAAI,CAAC;AAElC,MAAM,SAAS,GAAG;IAChB;;;OAGG;IACH,gBAAgB;QACd,OAAO,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED;;MAEE;IACF,oBAAoB;QAClB,eAAe,CAAC,oBAAoB,EAAE,CAAC;IACzC,CAAC;IAED;;MAEE;IACF,oBAAoB,CAAC,QAA2B;QAC9C,iBAAiB,GAAG,QAAQ,CAAC;QAC7B,eAAe,CAAC,oBAAoB,EAAE,CAAC;QACvC,MAAM,YAAY,GAAG,IAAI,iCAAkB,CAAC,eAAe,CAAC,CAAC;QAC7D,YAAY,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YAC3C,IAAG,iBAAiB,EAAC;gBACnB,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA,CAAC,CAAC,KAAK,CAAC,CAAC;gBAChF,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;aACnC;QACH,CAAC,CAAC,CAAC;QAEH,YAAY,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YAC9C,IAAG,iBAAiB,EAAC;gBACnB,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA,CAAC,CAAC,KAAK,CAAC,CAAC;gBAChF,iBAAiB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;aACtC;QACH,CAAC,CAAC,CAAC;QAEH,YAAY,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE;YACtD,IAAI,iBAAiB,EAAC;gBACpB,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA,CAAC,CAAC,KAAK,CAAC,CAAC;gBAChF,MAAM,iBAAiB,GAAY,iBAAiB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;gBAChF,eAAe,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACpF,cAAc,GAAG,IAAI,CAAC;aACvB;QACH,CAAC,CAAC,CAAC;QAEH,YAAY,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YAC9C,IAAG,iBAAiB,EAAC;gBACnB,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;gBACtB,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA,CAAC,CAAC,KAAK,CAAC,CAAC;gBAChF,iBAAiB,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;aAC3C;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;MAKE;IACF,WAAW,CAAC,OAAgB;QAC1B,cAAc,GAAG,OAAO,CAAC,EAAE,CAAC;IAC9B,CAAC;CACF,CAAC;AAEF,kBAAe,SAAS,CAAC"}
package/js/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;;AAEF,oEAAoC;AAK3B,oBALF,mBAAS,CAKE;AAJlB,uEAAuC;AAInB,kBAJb,iBAAO,CAIa;AAF3B,qGAAqE;AAErB,iCAFzC,gCAAsB,CAEyC"}
@@ -1,43 +0,0 @@
1
- declare class Message {
2
- id: string;
3
- autoTrack: boolean;
4
- constructor(id: string, autoTrack: boolean);
5
- /**
6
- * Update the value of property "autoTrack"
7
- * This function works only for the Message objects that were saved by calling "Messaging.saveMessage"
8
- * @param {boolean} autoTrack: New value of property autoTrack.
9
- */
10
- setAutoTrack(autoTrack: boolean): void;
11
- /**
12
- * Signals to the UIServices that the message should be shown.
13
- * If autoTrack is true, calling this method will result in an "inapp.display" Edge Event being dispatched.
14
- */
15
- show(): void;
16
- /**
17
- * Signals to the UIServices that the message should be dismissed.
18
- * If `autoTrack` is true, calling this method will result in an "inapp.dismiss" Edge Event being dispatched.
19
- * @param {boolean?} suppressAutoTrack: if set to true, the inapp.dismiss Edge Event will not be sent regardless
20
- * of the autoTrack setting.
21
- */
22
- dismiss(suppressAutoTrack?: boolean): void;
23
- /**
24
- * Generates an Edge Event for the provided interaction and eventType.
25
- * @param {string?} interaction: a custom String value to be recorded in the interaction
26
- * @param {MessagingEdgeEventType} eventType: the MessagingEdgeEventType to be used for the ensuing Edge Event
27
- */
28
- track(interaction: string, eventType: number): void;
29
- /**
30
- * Adds a handler for Javascript messages sent from the message's webview.
31
- * The parameter passed to `handler` will contain the body of the message passed from the webview's Javascript.
32
- * @param {string} name: the name of the message that should be handled by `handler`
33
- * @return {Promise<any?>}: the Promise to be resolved with the body of the message passed by the Javascript message in the WebView
34
- */
35
- handleJavascriptMessage(name: string): Promise<any>;
36
- /**
37
- * Clears the reference to the Message object.
38
- * This function must be called if Message was saved by calling "Messaging.saveMessage" but no longer needed.
39
- * Failure to call this function leads to memory leaks.
40
- */
41
- clear(): void;
42
- }
43
- export default Message;
@@ -1,80 +0,0 @@
1
- "use strict";
2
- /*
3
- Copyright 2022 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) {
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
- /**
32
- * Signals to the UIServices that the message should be shown.
33
- * If autoTrack is true, calling this method will result in an "inapp.display" Edge Event being dispatched.
34
- */
35
- show() {
36
- RCTAEPMessaging.show(this.id);
37
- }
38
- ;
39
- /**
40
- * Signals to the UIServices that the message should be dismissed.
41
- * If `autoTrack` is true, calling this method will result in an "inapp.dismiss" Edge Event being dispatched.
42
- * @param {boolean?} suppressAutoTrack: if set to true, the inapp.dismiss Edge Event will not be sent regardless
43
- * of the autoTrack setting.
44
- */
45
- dismiss(suppressAutoTrack) {
46
- RCTAEPMessaging.dismiss(this.id, suppressAutoTrack ? true : false);
47
- }
48
- ;
49
- /**
50
- * Generates an Edge Event for the provided interaction and eventType.
51
- * @param {string?} interaction: a custom String value to be recorded in the interaction
52
- * @param {MessagingEdgeEventType} eventType: the MessagingEdgeEventType to be used for the ensuing Edge Event
53
- */
54
- track(interaction, eventType) {
55
- RCTAEPMessaging.track(this.id, interaction, eventType);
56
- }
57
- ;
58
- /**
59
- * Adds a handler for Javascript messages sent from the message's webview.
60
- * The parameter passed to `handler` will contain the body of the message passed from the webview's Javascript.
61
- * @param {string} name: the name of the message that should be handled by `handler`
62
- * @return {Promise<any?>}: the Promise to be resolved with the body of the message passed by the Javascript message in the WebView
63
- */
64
- handleJavascriptMessage(name) {
65
- return Promise.resolve(RCTAEPMessaging.handleJavascriptMessage(this.id, name));
66
- }
67
- ;
68
- /**
69
- * Clears the reference to the Message object.
70
- * This function must be called if Message was saved by calling "Messaging.saveMessage" but no longer needed.
71
- * Failure to call this function leads to memory leaks.
72
- */
73
- clear() {
74
- RCTAEPMessaging.clear(this.id);
75
- }
76
- ;
77
- }
78
- ;
79
- exports.default = Message;
80
- //# sourceMappingURL=Message.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Message.js","sourceRoot":"","sources":["../../ts/models/Message.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;AAEF,+CAA6C;AAC7C,MAAM,eAAe,GAAG,4BAAa,CAAC,YAAY,CAAC;AAEnD,MAAM,OAAO;IAIT,YAAY,EAAU,EAAE,SAAkB;QACtC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,SAAkB;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;IAAA,CAAC;IAEF;;;MAGE;IACF,IAAI;QACA,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IAAA,CAAC;IAEF;;;;;MAKE;IACF,OAAO,CAAC,iBAA2B;QAC/B,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACvE,CAAC;IAAA,CAAC;IAEF;;;;OAIG;IACH,KAAK,CAAC,WAAmB,EAAE,SAAiB;QACxC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAC3D,CAAC;IAAA,CAAC;IAEF;;;;;MAKE;IACF,uBAAuB,CAAC,IAAY;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;IACnF,CAAC;IAAA,CAAC;IAEF;;;;OAIG;IACH,KAAK;QACD,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;IAAA,CAAC;CACL;AAAA,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -1,25 +0,0 @@
1
- import Message from "./Message";
2
- export type 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 find whether messages should be shown or not
15
- * @param {Message} message: Message that is about to get displayed
16
- * @returns {boolean}: true if the message should be shown else false
17
- */
18
- shouldShowMessage(message: Message): boolean;
19
- /**
20
- * Called when message loads a URL
21
- * @param {string} url: the URL being loaded by the message
22
- * @param {Message} message: the Message loading a URL
23
- */
24
- urlLoaded(url: string, message: Message): void;
25
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"MessagingDelegate.js","sourceRoot":"","sources":["../../ts/models/MessagingDelegate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MessagingEdgeEventType.js","sourceRoot":"","sources":["../../ts/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"}
package/ts/Messaging.ts DELETED
@@ -1,99 +0,0 @@
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
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
-
13
- import { NativeModules, NativeEventEmitter, NativeModule } from 'react-native';
14
- import Message from './models/Message';
15
- import { MessagingDelegate } from "./models/MessagingDelegate";
16
-
17
- export interface IMessaging {
18
- extensionVersion: () => Promise<string>;
19
- refreshInAppMessages: () => void;
20
- setMessagingDelegate: (delegate?: MessagingDelegate) => void;
21
- shouldShowMessage: (shouldShowMessage: boolean, shouldSaveMessage: boolean) => void;
22
- saveMessage: (message: Message) => void;
23
- }
24
-
25
- const RCTAEPMessaging: NativeModule & IMessaging = NativeModules.AEPMessaging;
26
-
27
- declare var messagingDelegate: MessagingDelegate
28
- declare var savedMessageId: string;
29
-
30
- var messagingDelegate: MessagingDelegate;
31
- var savedMessageId: string = null;
32
-
33
- const Messaging = {
34
- /**
35
- * Returns the version of the AEPMessaging extension
36
- * @returns {string} Promise a promise that resolves with the extension version
37
- */
38
- extensionVersion(): Promise<string> {
39
- return Promise.resolve(RCTAEPMessaging.extensionVersion());
40
- },
41
-
42
- /**
43
- * Initiates a network call to retrieve remote In-App Message definitions.
44
- */
45
- refreshInAppMessages() {
46
- RCTAEPMessaging.refreshInAppMessages();
47
- },
48
-
49
- /**
50
- * Function to set the UI Message delegate to listen the Message lifecycle events.
51
- */
52
- setMessagingDelegate(delegate: MessagingDelegate) {
53
- messagingDelegate = delegate;
54
- RCTAEPMessaging.setMessagingDelegate();
55
- const eventEmitter = new NativeEventEmitter(RCTAEPMessaging);
56
- eventEmitter.addListener('onShow', (event) => {
57
- if(messagingDelegate){
58
- const message = new Message(event.id, event.autoTrack === "true" ? true: false);
59
- messagingDelegate.onShow(message);
60
- }
61
- });
62
-
63
- eventEmitter.addListener('onDismiss', (event) => {
64
- if(messagingDelegate){
65
- const message = new Message(event.id, event.autoTrack === "true" ? true: false);
66
- messagingDelegate.onDismiss(message);
67
- }
68
- });
69
-
70
- eventEmitter.addListener('shouldShowMessage', (event) => {
71
- if (messagingDelegate){
72
- const message = new Message(event.id, event.autoTrack === "true" ? true: false);
73
- const shouldShowMessage: boolean = messagingDelegate.shouldShowMessage(message);
74
- RCTAEPMessaging.shouldShowMessage(shouldShowMessage, savedMessageId ? true : false);
75
- savedMessageId = null;
76
- }
77
- });
78
-
79
- eventEmitter.addListener('urlLoaded', (event) => {
80
- if(messagingDelegate){
81
- const url = event.url;
82
- const message = new Message(event.id, event.autoTrack === "true" ? true: false);
83
- messagingDelegate.urlLoaded(url, message);
84
- }
85
- });
86
- },
87
-
88
- /**
89
- * Cache the Message object in-memory to use later.
90
- * If there is a requirement to call the Message functions like show, dismiss etc. The Message object should be saved first before calling it's functions.
91
- * If the Message is saved using this API then it is responsibility of App to free it after using.
92
- * To remove the Message from memory call clearMessage function of Message. Failure to call clearMessage will cause the Memory leak of Message object.
93
- */
94
- saveMessage(message: Message) {
95
- savedMessageId = message.id;
96
- },
97
- };
98
-
99
- export default Messaging;
@@ -1,82 +0,0 @@
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
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
-
13
- import { NativeModules } from 'react-native';
14
- const RCTAEPMessaging = NativeModules.AEPMessaging;
15
-
16
- class Message {
17
- id: string;
18
- autoTrack: boolean;
19
-
20
- constructor(id: string, autoTrack: boolean) {
21
- this.id = id;
22
- this.autoTrack = autoTrack;
23
- }
24
-
25
- /**
26
- * Update the value of property "autoTrack"
27
- * This function works only for the Message objects that were saved by calling "Messaging.saveMessage"
28
- * @param {boolean} autoTrack: New value of property autoTrack.
29
- */
30
- setAutoTrack(autoTrack: boolean) {
31
- this.autoTrack = autoTrack;
32
- RCTAEPMessaging.setAutoTrack(this.id, autoTrack);
33
- };
34
-
35
- /**
36
- * Signals to the UIServices that the message should be shown.
37
- * If autoTrack is true, calling this method will result in an "inapp.display" Edge Event being dispatched.
38
- */
39
- show() {
40
- RCTAEPMessaging.show(this.id);
41
- };
42
-
43
- /**
44
- * Signals to the UIServices that the message should be dismissed.
45
- * If `autoTrack` is true, calling this method will result in an "inapp.dismiss" Edge Event being dispatched.
46
- * @param {boolean?} suppressAutoTrack: if set to true, the inapp.dismiss Edge Event will not be sent regardless
47
- * of the autoTrack setting.
48
- */
49
- dismiss(suppressAutoTrack?: boolean) {
50
- RCTAEPMessaging.dismiss(this.id, suppressAutoTrack ? true : false);
51
- };
52
-
53
- /**
54
- * Generates an Edge Event for the provided interaction and eventType.
55
- * @param {string?} interaction: a custom String value to be recorded in the interaction
56
- * @param {MessagingEdgeEventType} eventType: the MessagingEdgeEventType to be used for the ensuing Edge Event
57
- */
58
- track(interaction: string, eventType: number) {
59
- RCTAEPMessaging.track(this.id, interaction, eventType);
60
- };
61
-
62
- /**
63
- * Adds a handler for Javascript messages sent from the message's webview.
64
- * The parameter passed to `handler` will contain the body of the message passed from the webview's Javascript.
65
- * @param {string} name: the name of the message that should be handled by `handler`
66
- * @return {Promise<any?>}: the Promise to be resolved with the body of the message passed by the Javascript message in the WebView
67
- */
68
- handleJavascriptMessage(name: string) : Promise<any> {
69
- return Promise.resolve(RCTAEPMessaging.handleJavascriptMessage(this.id, name));
70
- };
71
-
72
- /**
73
- * Clears the reference to the Message object.
74
- * This function must be called if Message was saved by calling "Messaging.saveMessage" but no longer needed.
75
- * Failure to call this function leads to memory leaks.
76
- */
77
- clear() {
78
- RCTAEPMessaging.clear(this.id);
79
- };
80
- };
81
-
82
- export default Message;
@@ -1,41 +0,0 @@
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
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
-
13
- import Message from "./Message";
14
-
15
- export type MessagingDelegate = {
16
- /**
17
- * Invoked when the any message is displayed
18
- * @param {Message} message: Message that is being displayed.
19
- */
20
- onShow(message: Message): void;
21
-
22
- /**
23
- * Invoked when any message is dismissed
24
- * @param {Message} message: Message that is being dismissed
25
- */
26
- onDismiss(message: Message): void;
27
-
28
- /**
29
- * Used to find whether messages should be shown or not
30
- * @param {Message} message: Message that is about to get displayed
31
- * @returns {boolean}: true if the message should be shown else false
32
- */
33
- shouldShowMessage(message: Message): boolean;
34
-
35
- /**
36
- * Called when message loads a URL
37
- * @param {string} url: the URL being loaded by the message
38
- * @param {Message} message: the Message loading a URL
39
- */
40
- urlLoaded(url: string, message: Message): void;
41
- };
File without changes
File without changes