@adobe/react-native-aepmessaging 1.0.0-beta.2 → 1.0.0-beta.3

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.
@@ -8,11 +8,34 @@
8
8
  OF ANY KIND, either express or implied. See the License for the specific language
9
9
  governing permissions and limitations under the License.
10
10
  */
11
-
12
11
  #import "RCTAEPMessaging.h"
13
12
  @import AEPMessaging;
13
+ @import AEPCore;
14
+
15
+ static NSString* const TAG = @"RCTAEPMessaging";
16
+
17
+ @implementation RCTAEPMessaging {
18
+ NSMutableDictionary<NSString*, AEPMessage*> * cachedMessages;
19
+ dispatch_semaphore_t semaphore;
20
+ bool shouldShowMessage;
21
+ bool hasListeners;
22
+ bool shouldSaveMessage;
23
+ }
14
24
 
15
- @implementation RCTAEPMessaging
25
+ - (instancetype) init {
26
+ self = [super init];
27
+ cachedMessages = [NSMutableDictionary dictionary];
28
+ semaphore = dispatch_semaphore_create(0);
29
+ hasListeners = false;
30
+ shouldShowMessage = true;
31
+ shouldSaveMessage = false;
32
+ return self;
33
+ }
34
+
35
+ + (BOOL)requiresMainQueueSetup
36
+ {
37
+ return NO;
38
+ }
16
39
 
17
40
  RCT_EXPORT_MODULE(AEPMessaging);
18
41
 
@@ -24,5 +47,150 @@ RCT_EXPORT_MODULE(AEPMessaging);
24
47
  RCT_EXPORT_METHOD(extensionVersion: (RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject) {
25
48
  resolve([AEPMobileMessaging extensionVersion]);
26
49
  }
50
+
51
+ RCT_EXPORT_METHOD(refreshInAppMessages) {
52
+ [AEPLog traceWithLabel:TAG message:@"refreshInAppMessages is called."];
53
+ [AEPMobileMessaging refreshInAppMessages];
54
+ }
55
+
56
+ RCT_EXPORT_METHOD(setMessagingDelegate) {
57
+ [AEPLog traceWithLabel:TAG message:@"Messaging Delegate is set."];
58
+ [AEPMobileCore setMessagingDelegate: self];
59
+ }
60
+
61
+ RCT_EXPORT_METHOD(show: (NSString *) messageId) {
62
+ [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"show is called with message id: %@", messageId]];
63
+ AEPMessage * message = [cachedMessages objectForKey:messageId];
64
+ if(message){
65
+ [message show];
66
+ }
67
+ }
68
+
69
+ RCT_EXPORT_METHOD(dismiss: (NSString *) messageId suppressAutoTrack: (BOOL) suppressAutoTrack) {
70
+ [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"dismiss is called with message id: %@ and suppressAutoTrack: %i", messageId, suppressAutoTrack]];
71
+ AEPMessage * message = [cachedMessages objectForKey:messageId];
72
+ if(message){
73
+ [message dismissSuppressingAutoTrack:suppressAutoTrack];
74
+ }
75
+ }
76
+
77
+ RCT_EXPORT_METHOD(track: (NSString *) messageId withInteraction: (NSString *) interaction eventType: (int) eventTypeValue) {
78
+ [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"track is called with message id: %@, withInteraction: %@ and eventType: %i", messageId, interaction, eventTypeValue]];
79
+ AEPMessage * message = [cachedMessages objectForKey:messageId];
80
+ AEPMessagingEdgeEventType messagingEdgeEventType = -1;
81
+
82
+ if(eventTypeValue == 0){
83
+ messagingEdgeEventType = AEPMessagingEdgeEventTypeInappDismiss;
84
+ } else if (eventTypeValue == 1) {
85
+ messagingEdgeEventType = AEPMessagingEdgeEventTypeInappInteract;
86
+ } else if (eventTypeValue == 2) {
87
+ messagingEdgeEventType = AEPMessagingEdgeEventTypeInappTrigger;
88
+ } else if (eventTypeValue == 3) {
89
+ messagingEdgeEventType = AEPMessagingEdgeEventTypeInappDisplay;
90
+ } else if (eventTypeValue == 4) {
91
+ messagingEdgeEventType = AEPMessagingEdgeEventTypePushApplicationOpened;
92
+ } else if (eventTypeValue == 5) {
93
+ messagingEdgeEventType = AEPMessagingEdgeEventTypePushCustomAction;
94
+ }
95
+
96
+ if(messagingEdgeEventType != -1){
97
+ [message trackInteraction:interaction withEdgeEventType:messagingEdgeEventType];
98
+ }
99
+ }
100
+
101
+ RCT_EXPORT_METHOD(handleJavascriptMessage: (NSString *) messageId
102
+ messageName: (NSString *) name resolver: (RCTPromiseResolveBlock) resolve rejector:(RCTPromiseRejectBlock) reject) {
103
+ [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"handleJavascriptMessage is called with message id: %@ and messageName: %@", messageId, name]];
104
+ AEPMessage * message = [cachedMessages objectForKey: messageId];
105
+ [message handleJavascriptMessage:name withHandler:^(id result) {
106
+ if(result) {
107
+ resolve(result);
108
+ } else {
109
+ reject(@"error", @"error in handleJavaScriptMessage", nil);
110
+ }
111
+ }];
112
+ }
113
+
114
+ RCT_EXPORT_METHOD(clear: (NSString *) messageId) {
115
+ [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"clearMessage is called with message id: %@", messageId]];
116
+ [cachedMessages removeObjectForKey:messageId];
117
+ }
118
+
119
+ RCT_EXPORT_METHOD(setAutoTrack: (NSString *) messageId autoTrack: (BOOL) autoTrack) {
120
+ [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"setAutoTrack called for messageId: %@ and autoTrack value: %i", messageId, autoTrack]];
121
+ AEPMessage * messageObj = [cachedMessages objectForKey:messageId];
122
+ if(messageObj) {
123
+ messageObj.autoTrack = autoTrack;
124
+ }
125
+ }
126
+
127
+ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(shouldShowMessage: (BOOL) shouldShowMessage shouldSaveMessage: (BOOL) saveMessage) {
128
+ [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"shouldShowMessage is called with values (shouldShowMessage: %i) and (shouldSaveMessage: %i)", shouldShowMessage, shouldSaveMessage]];
129
+ self->shouldShowMessage = shouldShowMessage;
130
+ self->shouldSaveMessage = saveMessage;
131
+ dispatch_semaphore_signal(semaphore);
132
+ return nil;
133
+ }
134
+
135
+ //MARK: - AEPMessagingDelegate functions.
136
+ - (void) onDismissWithMessage:(id<AEPShowable> _Nonnull) message {
137
+ AEPFullscreenMessage * fullscreenMessage = (AEPFullscreenMessage *) message;
138
+ AEPMessage * messageObj = (AEPMessage *) fullscreenMessage.settings.parent;
139
+ if(messageObj) {
140
+ [self emitEventWithName:@"onDismiss" body:@{@"id":messageObj.id, @"autoTrack":messageObj.autoTrack ? @"true" : @"false"}];
141
+ }
142
+ }
143
+
144
+ - (void) onShowWithMessage:(id<AEPShowable> _Nonnull)message {
145
+ AEPFullscreenMessage * fullscreenMessage = (AEPFullscreenMessage *) message;
146
+ AEPMessage * messageObj = (AEPMessage *) fullscreenMessage.settings.parent;
147
+ if(messageObj) {
148
+ [self emitEventWithName:@"onShow" body:@{@"id":messageObj.id, @"autoTrack":messageObj.autoTrack ? @"true" : @"false"}];
149
+ }
150
+ }
151
+
152
+ - (BOOL) shouldShowMessageWithMessage:(id<AEPShowable> _Nonnull)message {
153
+ AEPFullscreenMessage * fullscreenMessage = (AEPFullscreenMessage *) message;
154
+ AEPMessage * messageObj = (AEPMessage *) fullscreenMessage.settings.parent;
155
+ if(messageObj) {
156
+ [self emitEventWithName:@"shouldShowMessage" body:@{@"id":messageObj.id, @"autoTrack":messageObj.autoTrack ? @"true" : @"false"}];
157
+ //Semaphore stops the thread until the value to be returned from this function is received from the JS side on thread dedicated to run JS code. The function called from JS that unlock the Semaphore is "shouldShowMessage".
158
+ [AEPLog traceWithLabel:TAG message:@"Semaphore lock initiated."];
159
+ dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
160
+ [AEPLog traceWithLabel:TAG message:@"Semaphore lock removed."];
161
+ if(self->shouldSaveMessage) {
162
+ [AEPLog traceWithLabel:TAG message:[[NSString alloc] initWithFormat:@"Message is saved with id: %@", messageObj.id]];
163
+ [cachedMessages setObject:messageObj forKey:messageObj.id];
164
+ }
165
+ }
166
+ return self->shouldShowMessage;
167
+ }
168
+
169
+ - (void) urlLoaded:(NSURL *)url byMessage:(id<AEPShowable>)message {
170
+ AEPFullscreenMessage * fullscreenMessage = (AEPFullscreenMessage *) message;
171
+ AEPMessage * messageObj = (AEPMessage *) fullscreenMessage.settings.parent;
172
+ if(messageObj){
173
+ [self emitEventWithName:@"urlLoaded" body:@{@"id":messageObj.id, @"autoTrack":messageObj.autoTrack ? @"true" : @"false", @"url":url.absoluteString}];
174
+ }
175
+ }
176
+
177
+ - (NSArray<NSString *> *) supportedEvents {
178
+ return @[@"onShow", @"onDismiss", @"shouldShowMessage",@"urlLoaded"];
179
+ }
180
+
181
+ - (void) startObserving {
182
+ hasListeners = true;
183
+ }
184
+
185
+ - (void) stopObserving {
186
+ hasListeners = false;
187
+ }
188
+
189
+ - (void) emitEventWithName: (NSString *) name body: (NSDictionary<NSString*, NSString*> *) dictionary {
190
+ if(hasListeners){
191
+ [AEPLog traceWithLabel:TAG message:[NSString stringWithFormat:@"Event emitted with name: %@", name]];
192
+ [self sendEventWithName:name body:dictionary];
193
+ }
194
+ }
195
+
27
196
  @end
28
-
package/js/Messaging.d.ts CHANGED
@@ -1,5 +1,32 @@
1
- interface IMessaging {
1
+ import Message from './models/Message';
2
+ import { MessagingDelegate } from "./models/MessagingDelegate";
3
+ export interface IMessaging {
2
4
  extensionVersion: () => Promise<string>;
5
+ refreshInAppMessages: () => void;
6
+ setMessagingDelegate: (delegate?: MessagingDelegate) => void;
7
+ shouldShowMessage: (shouldShowMessage: boolean, shouldSaveMessage: boolean) => void;
8
+ saveMessage: (message: Message) => void;
3
9
  }
4
- declare const Messaging: IMessaging;
10
+ declare const Messaging: {
11
+ /**
12
+ * Returns the version of the AEPMessaging extension
13
+ * @returns {string} Promise a promise that resolves with the extension version
14
+ */
15
+ extensionVersion(): Promise<string>;
16
+ /**
17
+ * Initiates a network call to retrieve remote In-App Message definitions.
18
+ */
19
+ refreshInAppMessages(): void;
20
+ /**
21
+ * Function to set the UI Message delegate to listen the Message lifecycle events.
22
+ */
23
+ setMessagingDelegate(delegate: MessagingDelegate): void;
24
+ /**
25
+ * Cache the Message object in-memory to use later.
26
+ * 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.
27
+ * If the Message is saved using this API then it is responsibility of App to free it after using.
28
+ * To remove the Message from memory call clearMessage function of Message. Failure to call clearMessage will cause the Memory leak of Message object.
29
+ */
30
+ saveMessage(message: Message): void;
31
+ };
5
32
  export default Messaging;
package/js/Messaging.js CHANGED
@@ -11,16 +11,70 @@ OF ANY KIND, either express or implied. See the License for the specific languag
11
11
  governing permissions and limitations under the License.
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
+ const tslib_1 = require("tslib");
14
15
  const react_native_1 = require("react-native");
16
+ const Message_1 = tslib_1.__importDefault(require("./models/Message"));
15
17
  const RCTAEPMessaging = react_native_1.NativeModules.AEPMessaging;
18
+ var messagingDelegate;
19
+ var savedMessageId = null;
16
20
  const Messaging = {
17
21
  /**
18
22
  * Returns the version of the AEPMessaging extension
19
- * @param {string} Promise a promise that resolves with the extension version
23
+ * @returns {string} Promise a promise that resolves with the extension version
20
24
  */
21
25
  extensionVersion() {
22
26
  return Promise.resolve(RCTAEPMessaging.extensionVersion());
23
- }
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
+ },
24
78
  };
25
79
  exports.default = Messaging;
26
80
  //# sourceMappingURL=Messaging.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Messaging.js","sourceRoot":"","sources":["../ts/Messaging.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;AAEF,+CAA6C;AAM7C,MAAM,eAAe,GAAe,4BAAa,CAAC,YAAY,CAAC;AAE/D,MAAM,SAAS,GAAe;IAC5B;;;OAGG;IACH,gBAAgB;QACd,OAAO,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF,CAAC;AAEF,kBAAe,SAAS,CAAC"}
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,IA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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.d.ts CHANGED
@@ -1,2 +1,5 @@
1
1
  import Messaging from './Messaging';
2
- export { Messaging };
2
+ import Message from './models/Message';
3
+ import { MessagingDelegate } from './models/MessagingDelegate';
4
+ import MessagingEdgeEventType from './models/MessagingEdgeEventType';
5
+ export { Messaging, Message, MessagingDelegate, MessagingEdgeEventType };
package/js/index.js CHANGED
@@ -11,8 +11,12 @@ OF ANY KIND, either express or implied. See the License for the specific languag
11
11
  governing permissions and limitations under the License.
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.Messaging = void 0;
14
+ exports.MessagingEdgeEventType = exports.Message = exports.Messaging = void 0;
15
15
  const tslib_1 = require("tslib");
16
- const Messaging_1 = (0, tslib_1.__importDefault)(require("./Messaging"));
16
+ const Messaging_1 = tslib_1.__importDefault(require("./Messaging"));
17
17
  exports.Messaging = Messaging_1.default;
18
+ const Message_1 = tslib_1.__importDefault(require("./models/Message"));
19
+ exports.Message = Message_1.default;
20
+ const MessagingEdgeEventType_1 = tslib_1.__importDefault(require("./models/MessagingEdgeEventType"));
21
+ exports.MessagingEdgeEventType = MessagingEdgeEventType_1.default;
18
22
  //# sourceMappingURL=index.js.map
package/js/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;;AAEF,yEAAoC;AAE3B,oBAFF,mBAAS,CAEE"}
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"}
@@ -0,0 +1,43 @@
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;
@@ -0,0 +1,80 @@
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
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AE,CAAC,CAAC;IACnC,CAAC;IAAA,CAAC;CACL;AAAA,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,25 @@
1
+ import Message from "./Message";
2
+ export declare 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
+ };
@@ -0,0 +1,14 @@
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
+ //# sourceMappingURL=MessagingDelegate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessagingDelegate.js","sourceRoot":"","sources":["../../ts/models/MessagingDelegate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE"}
@@ -0,0 +1,9 @@
1
+ declare enum MessagingEdgeEventType {
2
+ IN_APP_DISMISS = 0,
3
+ IN_APP_INTERACT = 1,
4
+ IN_APP_TRIGGER = 2,
5
+ IN_APP_DISPLAY = 3,
6
+ PUSH_APPLICATION_OPENED = 4,
7
+ PUSH_CUSTOM_ACTION = 5
8
+ }
9
+ export default MessagingEdgeEventType;
@@ -0,0 +1,25 @@
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
+ var MessagingEdgeEventType;
15
+ (function (MessagingEdgeEventType) {
16
+ MessagingEdgeEventType[MessagingEdgeEventType["IN_APP_DISMISS"] = 0] = "IN_APP_DISMISS";
17
+ MessagingEdgeEventType[MessagingEdgeEventType["IN_APP_INTERACT"] = 1] = "IN_APP_INTERACT";
18
+ MessagingEdgeEventType[MessagingEdgeEventType["IN_APP_TRIGGER"] = 2] = "IN_APP_TRIGGER";
19
+ MessagingEdgeEventType[MessagingEdgeEventType["IN_APP_DISPLAY"] = 3] = "IN_APP_DISPLAY";
20
+ MessagingEdgeEventType[MessagingEdgeEventType["PUSH_APPLICATION_OPENED"] = 4] = "PUSH_APPLICATION_OPENED";
21
+ MessagingEdgeEventType[MessagingEdgeEventType["PUSH_CUSTOM_ACTION"] = 5] = "PUSH_CUSTOM_ACTION";
22
+ })(MessagingEdgeEventType || (MessagingEdgeEventType = {}));
23
+ ;
24
+ exports.default = MessagingEdgeEventType;
25
+ //# sourceMappingURL=MessagingEdgeEventType.js.map
@@ -0,0 +1 @@
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/react-native-aepmessaging",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "Adobe Experience Platform support for React Native apps.",
5
5
  "homepage": "https://aep-sdks.gitbook.io/docs/",
6
6
  "license": "Apache-2.0",
@@ -27,13 +27,13 @@
27
27
  "name": "Adobe Experience Platform SDK Team"
28
28
  },
29
29
  "peerDependencies": {
30
- "@adobe/react-native-aepcore": "^1.0.0-beta",
31
- "@adobe/react-native-aepedge": "^1.0.0-beta",
32
- "@adobe/react-native-aepedgeidentity": "^1.0.0-beta",
30
+ "@adobe/react-native-aepcore": "^1.0.0",
31
+ "@adobe/react-native-aepedge": "^1.0.0",
32
+ "@adobe/react-native-aepedgeidentity": "^1.0.0",
33
33
  "react-native": ">=0.60.0"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "a7d0febed8bcb7c58025bff4daa6a974953f3de4"
38
+ "gitHead": "1c811791e996dbb95951f26bdd77306f547a4e04"
39
39
  }