@adobe/react-native-aepmessaging 5.1.0-beta.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RCTAEPMessaging.podspec +3 -3
- package/README.md +13 -30
- package/android/build.gradle +1 -4
- package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingModule.java +41 -95
- package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingUtil.java +17 -14
- package/dist/Messaging.js +8 -2
- package/dist/Messaging.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/models/Message.d.ts +0 -7
- package/dist/models/Message.js +0 -9
- package/dist/models/Message.js.map +1 -1
- package/dist/models/MessagingDelegate.d.ts +6 -1
- package/dist/models/MessagingEdgeEventType.d.ts +4 -4
- package/dist/models/MessagingEdgeEventType.js +4 -4
- package/dist/models/MessagingEdgeEventType.js.map +1 -1
- package/dist/models/MessagingPropositionItem.d.ts +5 -3
- package/dist/models/MessagingPropositionItem.js +0 -9
- package/dist/models/MessagingPropositionItem.js.map +1 -1
- package/ios/src/RCTAEPMessaging.swift +1 -18
- package/ios/src/RCTAEPMessagingDataBridge.swift +10 -4
- package/package.json +5 -5
- package/src/Messaging.ts +23 -6
- package/src/index.ts +10 -1
- package/src/models/Message.ts +0 -12
- package/src/models/MessagingDelegate.ts +7 -1
- package/src/models/MessagingEdgeEventType.ts +4 -4
- package/src/models/MessagingPropositionItem.ts +7 -10
package/RCTAEPMessaging.podspec
CHANGED
|
@@ -10,12 +10,12 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.author = "Adobe Experience Platform SDK Team"
|
|
11
11
|
s.homepage = "https://github.com/adobe/aepsdk-react-native"
|
|
12
12
|
s.license = "Apache 2.0 License"
|
|
13
|
-
s.platform = :ios, '
|
|
13
|
+
s.platform = :ios, '12.0'
|
|
14
14
|
s.source = { :git => "https://github.com/adobe/aepsdk-react-native.git", :tag => "#{s.version}" }
|
|
15
15
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
16
|
-
s.swift_version = '5.
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
17
|
|
|
18
|
-
s.dependency "AEPMessaging", "
|
|
18
|
+
s.dependency "AEPMessaging", ">= 5.0.0", "< 6.0.0"
|
|
19
19
|
|
|
20
20
|
if respond_to?(:install_modules_dependencies, true)
|
|
21
21
|
install_modules_dependencies(s)
|
package/README.md
CHANGED
|
@@ -31,30 +31,6 @@ Yarn:
|
|
|
31
31
|
yarn add @adobe/react-native-aepmessaging
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
## Code Based Propositions - Beta
|
|
35
|
-
|
|
36
|
-
To enable code based propositions, please use the beta version of the messaging extension 5.1.0-beta.1
|
|
37
|
-
|
|
38
|
-
NPM:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
npm install @adobe/react-native-aepmessaging@5.1.0-beta.1
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Yarn:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
yarn add @adobe/react-native-aepmessaging@5.1.0-beta.1
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Additionally, add the following to your applications iOS podfile:
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
target 'YourApp' do
|
|
54
|
-
...
|
|
55
|
-
pod 'AEPMessaging', :git => 'https://github.com/adobe/aepsdk-messaging-ios.git', :branch => 'exd-cbe-beta'
|
|
56
|
-
```
|
|
57
|
-
|
|
58
34
|
## Usage
|
|
59
35
|
|
|
60
36
|
### [Messaging](https://developer.adobe.com/client-sdks/documentation/adobe-journey-optimizer)
|
|
@@ -250,7 +226,7 @@ const messagingDelegate = {
|
|
|
250
226
|
};
|
|
251
227
|
```
|
|
252
228
|
|
|
253
|
-
### updatePropositionsForSurfaces
|
|
229
|
+
### updatePropositionsForSurfaces
|
|
254
230
|
|
|
255
231
|
Dispatches an event to fetch propositions for the provided surfaces from remote.
|
|
256
232
|
|
|
@@ -266,7 +242,7 @@ updatePropositionsForSurfaces(surfaces: string[])
|
|
|
266
242
|
Messaging.updatePropositionsForSurfaces(["mobileapp://my-surface"])
|
|
267
243
|
```
|
|
268
244
|
|
|
269
|
-
### getPropositionsForSurfaces
|
|
245
|
+
### getPropositionsForSurfaces
|
|
270
246
|
|
|
271
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.
|
|
272
248
|
|
|
@@ -283,7 +259,7 @@ const propositions = Messaging.getPropositionsForSurfaces(["mobileapp://my-surfa
|
|
|
283
259
|
console.log(propositions)
|
|
284
260
|
```
|
|
285
261
|
|
|
286
|
-
### getLatestMessage
|
|
262
|
+
### getLatestMessage
|
|
287
263
|
|
|
288
264
|
Retrieves the most recently displayed message object
|
|
289
265
|
|
|
@@ -300,7 +276,7 @@ const message = Messaging.getLatestMessage()
|
|
|
300
276
|
console.log(message.id)
|
|
301
277
|
```
|
|
302
278
|
|
|
303
|
-
### getCachedMessages
|
|
279
|
+
### getCachedMessages
|
|
304
280
|
|
|
305
281
|
Retrieves a list of all messages that have been cached in-memory
|
|
306
282
|
|
|
@@ -317,7 +293,7 @@ const messages = Messaging.getCachedMessages()
|
|
|
317
293
|
messages.forEach(message => message.clear())
|
|
318
294
|
```
|
|
319
295
|
|
|
320
|
-
### setMessageSettings
|
|
296
|
+
### setMessageSettings
|
|
321
297
|
|
|
322
298
|
Allows setting a global setting for `shouldSaveMessage` and `shouldShowMessage`. Use a messaging delegate defined in the `setMessagingDelegate` method for more fine-grained control of message settings
|
|
323
299
|
|
|
@@ -454,7 +430,9 @@ type MessagingDelegate = {
|
|
|
454
430
|
|
|
455
431
|
shouldShowMessage(message: Message): boolean,
|
|
456
432
|
|
|
457
|
-
urlLoaded(url: string, message: Message): void,
|
|
433
|
+
urlLoaded(url: string, message: Message): void, // iOS Only
|
|
434
|
+
|
|
435
|
+
onContentLoaded(message: Message): void, // Android Only
|
|
458
436
|
};
|
|
459
437
|
```
|
|
460
438
|
|
|
@@ -477,7 +455,12 @@ const messagingDelegate = {
|
|
|
477
455
|
urlLoaded(url: string, message: Message) {
|
|
478
456
|
// Action after message loads an URL
|
|
479
457
|
},
|
|
458
|
+
|
|
459
|
+
onContentLoaded(message: Message) {
|
|
460
|
+
// Action after message loads content
|
|
461
|
+
},
|
|
480
462
|
};
|
|
463
|
+
|
|
481
464
|
```
|
|
482
465
|
|
|
483
466
|
### Controlling when the message should be shown to the end user.
|
package/android/build.gradle
CHANGED
|
@@ -87,8 +87,6 @@ android {
|
|
|
87
87
|
repositories {
|
|
88
88
|
mavenCentral()
|
|
89
89
|
google()
|
|
90
|
-
maven { url "https://plugins.gradle.org/m2/" }
|
|
91
|
-
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
@@ -99,7 +97,6 @@ dependencies {
|
|
|
99
97
|
//noinspection GradleDynamicVersion
|
|
100
98
|
implementation "com.facebook.react:react-native:+"
|
|
101
99
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
102
|
-
|
|
103
|
-
api "com.adobe.marketing.mobile:messaging:2.3.0-cbe-beta-SNAPSHOT"
|
|
100
|
+
api "com.adobe.marketing.mobile:messaging:3.+"
|
|
104
101
|
implementation "com.facebook.react:react-native:+"
|
|
105
102
|
}
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
package com.adobe.marketing.mobile.reactnative.messaging;
|
|
13
13
|
|
|
14
14
|
import android.app.Activity;
|
|
15
|
+
|
|
16
|
+
import androidx.annotation.NonNull;
|
|
17
|
+
|
|
15
18
|
import com.adobe.marketing.mobile.AdobeCallback;
|
|
16
19
|
import com.adobe.marketing.mobile.AdobeCallbackWithError;
|
|
17
20
|
import com.adobe.marketing.mobile.AdobeError;
|
|
@@ -20,10 +23,13 @@ import com.adobe.marketing.mobile.Message;
|
|
|
20
23
|
import com.adobe.marketing.mobile.Messaging;
|
|
21
24
|
import com.adobe.marketing.mobile.MessagingEdgeEventType;
|
|
22
25
|
import com.adobe.marketing.mobile.MobileCore;
|
|
23
|
-
import com.adobe.marketing.mobile.messaging.
|
|
26
|
+
import com.adobe.marketing.mobile.messaging.MessagingUtils;
|
|
27
|
+
import com.adobe.marketing.mobile.messaging.Proposition;
|
|
24
28
|
import com.adobe.marketing.mobile.messaging.Surface;
|
|
25
|
-
import com.adobe.marketing.mobile.services.
|
|
26
|
-
import com.adobe.marketing.mobile.services.ui.
|
|
29
|
+
import com.adobe.marketing.mobile.services.ServiceProvider;
|
|
30
|
+
import com.adobe.marketing.mobile.services.ui.InAppMessage;
|
|
31
|
+
import com.adobe.marketing.mobile.services.ui.Presentable;
|
|
32
|
+
import com.adobe.marketing.mobile.services.ui.PresentationDelegate;
|
|
27
33
|
import com.facebook.react.bridge.Arguments;
|
|
28
34
|
import com.facebook.react.bridge.Promise;
|
|
29
35
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
@@ -38,7 +44,7 @@ import java.util.Map;
|
|
|
38
44
|
import java.util.concurrent.CountDownLatch;
|
|
39
45
|
|
|
40
46
|
public final class RCTAEPMessagingModule
|
|
41
|
-
extends ReactContextBaseJavaModule implements
|
|
47
|
+
extends ReactContextBaseJavaModule implements PresentationDelegate {
|
|
42
48
|
|
|
43
49
|
private static final String TAG = "RCTAEPMessagingModule";
|
|
44
50
|
private final Map<String, Message> messageCache = new HashMap<>();
|
|
@@ -67,7 +73,6 @@ public final class RCTAEPMessagingModule
|
|
|
67
73
|
|
|
68
74
|
@ReactMethod
|
|
69
75
|
public void extensionVersion(final Promise promise) {
|
|
70
|
-
MobileCore.log(LoggingMode.VERBOSE, TAG, "extensionVersion is called");
|
|
71
76
|
promise.resolve(Messaging.extensionVersion());
|
|
72
77
|
}
|
|
73
78
|
|
|
@@ -88,7 +93,7 @@ public final class RCTAEPMessagingModule
|
|
|
88
93
|
String bundleId = this.reactContext.getPackageName();
|
|
89
94
|
Messaging.getPropositionsForSurfaces(
|
|
90
95
|
RCTAEPMessagingUtil.convertSurfaces(surfaces),
|
|
91
|
-
new AdobeCallbackWithError<Map<Surface, List<
|
|
96
|
+
new AdobeCallbackWithError<Map<Surface, List<Proposition>>>() {
|
|
92
97
|
@Override
|
|
93
98
|
public void fail(final AdobeError adobeError) {
|
|
94
99
|
promise.reject(adobeError.getErrorName(),
|
|
@@ -97,7 +102,7 @@ public final class RCTAEPMessagingModule
|
|
|
97
102
|
|
|
98
103
|
@Override
|
|
99
104
|
public void call(
|
|
100
|
-
Map<Surface, List<
|
|
105
|
+
Map<Surface, List<Proposition>> propositionsMap) {
|
|
101
106
|
promise.resolve(RCTAEPMessagingUtil.convertSurfacePropositions(
|
|
102
107
|
propositionsMap, bundleId));
|
|
103
108
|
}
|
|
@@ -106,14 +111,12 @@ public final class RCTAEPMessagingModule
|
|
|
106
111
|
|
|
107
112
|
@ReactMethod
|
|
108
113
|
public void refreshInAppMessages() {
|
|
109
|
-
MobileCore.log(LoggingMode.VERBOSE, TAG, "refreshInAppMessages is called");
|
|
110
114
|
Messaging.refreshInAppMessages();
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
@ReactMethod
|
|
114
118
|
public void setMessagingDelegate() {
|
|
115
|
-
|
|
116
|
-
MobileCore.setMessagingDelegate(this);
|
|
119
|
+
ServiceProvider.getInstance().getUIService().setPresentationDelegate(this);
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
@ReactMethod
|
|
@@ -127,58 +130,20 @@ public final class RCTAEPMessagingModule
|
|
|
127
130
|
@ReactMethod
|
|
128
131
|
public void clear(final String messageId) {
|
|
129
132
|
if (messageId != null) {
|
|
130
|
-
MobileCore.log(
|
|
131
|
-
LoggingMode.VERBOSE, TAG,
|
|
132
|
-
String.format("clear is called with message id: %s", messageId));
|
|
133
133
|
messageCache.remove(messageId);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
@ReactMethod
|
|
138
|
-
public void dismiss(final String messageId
|
|
139
|
-
if (messageId != null && messageCache.get(messageId) != null) {
|
|
140
|
-
MobileCore.log(
|
|
141
|
-
LoggingMode.VERBOSE, TAG,
|
|
142
|
-
String.format(
|
|
143
|
-
"dismiss is called with message id: %s and suppressAutoTrack: %b",
|
|
144
|
-
messageId, suppressAutoTrack));
|
|
145
|
-
messageCache.get(messageId).dismiss(suppressAutoTrack);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
@ReactMethod
|
|
150
|
-
public void handleJavascriptMessage(final String messageId,
|
|
151
|
-
final String messageName,
|
|
152
|
-
final Promise promise) {
|
|
138
|
+
public void dismiss(final String messageId) {
|
|
153
139
|
if (messageId != null && messageCache.get(messageId) != null) {
|
|
154
|
-
|
|
155
|
-
LoggingMode.VERBOSE, TAG,
|
|
156
|
-
String.format(
|
|
157
|
-
"handleJavascriptMessage is called with message id: %s and messageName: %s",
|
|
158
|
-
messageId, messageName));
|
|
159
|
-
messageCache.get(messageId).handleJavascriptMessage(
|
|
160
|
-
messageName, new AdobeCallback<String>() {
|
|
161
|
-
@Override
|
|
162
|
-
public void call(final String s) {
|
|
163
|
-
if (s != null) {
|
|
164
|
-
promise.resolve(s);
|
|
165
|
-
} else {
|
|
166
|
-
promise.reject("error", "error in handling javascriptMessage " +
|
|
167
|
-
messageName);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
});
|
|
140
|
+
messageCache.get(messageId).dismiss();
|
|
171
141
|
}
|
|
172
142
|
}
|
|
173
143
|
|
|
174
144
|
@ReactMethod
|
|
175
145
|
public void setAutoTrack(final String messageId, final boolean autoTrack) {
|
|
176
146
|
if (messageId != null && messageCache.get(messageId) != null) {
|
|
177
|
-
MobileCore.log(
|
|
178
|
-
LoggingMode.VERBOSE, TAG,
|
|
179
|
-
String.format(
|
|
180
|
-
"setAutoTrack is called with message id: %s and autoTrack: %b",
|
|
181
|
-
messageId, autoTrack));
|
|
182
147
|
messageCache.get(messageId).setAutoTrack(autoTrack);
|
|
183
148
|
}
|
|
184
149
|
}
|
|
@@ -186,9 +151,6 @@ public final class RCTAEPMessagingModule
|
|
|
186
151
|
@ReactMethod
|
|
187
152
|
public void show(final String messageId) {
|
|
188
153
|
if (messageId != null && messageCache.get(messageId) != null) {
|
|
189
|
-
MobileCore.log(
|
|
190
|
-
LoggingMode.VERBOSE, TAG,
|
|
191
|
-
String.format("show is called with message id: %s", messageId));
|
|
192
154
|
messageCache.get(messageId).show();
|
|
193
155
|
}
|
|
194
156
|
}
|
|
@@ -197,30 +159,19 @@ public final class RCTAEPMessagingModule
|
|
|
197
159
|
public void track(final String messageId, final String interaction,
|
|
198
160
|
final int eventType) {
|
|
199
161
|
if (messageId != null && messageCache.get(messageId) != null) {
|
|
200
|
-
MobileCore.log(
|
|
201
|
-
LoggingMode.VERBOSE, TAG,
|
|
202
|
-
String.format(
|
|
203
|
-
"track is called with message id: %s, interaction: %s and eventType: %d",
|
|
204
|
-
messageId, interaction, eventType));
|
|
205
162
|
MessagingEdgeEventType edgeEventType =
|
|
206
163
|
RCTAEPMessagingUtil.getEventType(eventType);
|
|
207
164
|
if (edgeEventType != null) {
|
|
208
165
|
messageCache.get(messageId).track(interaction, edgeEventType);
|
|
209
|
-
} else {
|
|
210
|
-
MobileCore.log(
|
|
211
|
-
LoggingMode.DEBUG, TAG,
|
|
212
|
-
String.format(
|
|
213
|
-
"Unable to track interaction (%s) because edgeEventType (%d) is invalid ",
|
|
214
|
-
interaction, eventType));
|
|
215
166
|
}
|
|
216
167
|
}
|
|
217
168
|
}
|
|
218
169
|
|
|
219
170
|
// Messaging Delegate functions
|
|
220
171
|
@Override
|
|
221
|
-
public void onShow(final
|
|
222
|
-
|
|
223
|
-
|
|
172
|
+
public void onShow(final Presentable<?> presentable) {
|
|
173
|
+
if (!(presentable.getPresentation() instanceof InAppMessage)) return;
|
|
174
|
+
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
224
175
|
if (message != null) {
|
|
225
176
|
Map<String, String> data =
|
|
226
177
|
RCTAEPMessagingUtil.convertMessageToMap(message);
|
|
@@ -229,9 +180,9 @@ public final class RCTAEPMessagingModule
|
|
|
229
180
|
}
|
|
230
181
|
|
|
231
182
|
@Override
|
|
232
|
-
public void onDismiss(final
|
|
233
|
-
|
|
234
|
-
|
|
183
|
+
public void onDismiss(final Presentable<?> presentable) {
|
|
184
|
+
if (!(presentable.getPresentation() instanceof InAppMessage)) return;
|
|
185
|
+
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
235
186
|
if (message != null) {
|
|
236
187
|
Map<String, String> data =
|
|
237
188
|
RCTAEPMessagingUtil.convertMessageToMap(message);
|
|
@@ -240,9 +191,20 @@ public final class RCTAEPMessagingModule
|
|
|
240
191
|
}
|
|
241
192
|
|
|
242
193
|
@Override
|
|
243
|
-
public
|
|
244
|
-
|
|
245
|
-
|
|
194
|
+
public void onHide(final Presentable<?> presentable) {
|
|
195
|
+
if (!(presentable.getPresentation() instanceof InAppMessage)) return;
|
|
196
|
+
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
197
|
+
if (message != null) {
|
|
198
|
+
Map<String, String> data =
|
|
199
|
+
RCTAEPMessagingUtil.convertMessageToMap(message);
|
|
200
|
+
emitEvent("onHide", data);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@Override
|
|
205
|
+
public boolean canShow(final Presentable<?> presentable) {
|
|
206
|
+
if (!(presentable.getPresentation() instanceof InAppMessage)) return false;
|
|
207
|
+
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
246
208
|
if (message != null) {
|
|
247
209
|
Map<String, String> data =
|
|
248
210
|
RCTAEPMessagingUtil.convertMessageToMap(message);
|
|
@@ -250,17 +212,10 @@ public final class RCTAEPMessagingModule
|
|
|
250
212
|
// Latch stops the thread until the shouldShowMessage value is received
|
|
251
213
|
// from the JS side on thread dedicated to run JS code. The function
|
|
252
214
|
// called from JS that resumes the thread is "shouldShowMessage".
|
|
253
|
-
MobileCore.log(LoggingMode.VERBOSE, TAG,
|
|
254
|
-
"shouldShowMessage: Thread is locked.");
|
|
255
215
|
try {
|
|
256
216
|
latch.await();
|
|
257
217
|
} catch (final InterruptedException e) {
|
|
258
|
-
MobileCore.log(LoggingMode.ERROR, TAG,
|
|
259
|
-
String.format("CountDownLatch await Interrupted: (%s)",
|
|
260
|
-
e.getLocalizedMessage()));
|
|
261
218
|
}
|
|
262
|
-
MobileCore.log(LoggingMode.VERBOSE, TAG,
|
|
263
|
-
"shouldShowMessage: Thread is resumed.");
|
|
264
219
|
}
|
|
265
220
|
|
|
266
221
|
if (shouldShowMessage) {
|
|
@@ -274,17 +229,13 @@ public final class RCTAEPMessagingModule
|
|
|
274
229
|
return shouldShowMessage;
|
|
275
230
|
}
|
|
276
231
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
LoggingMode.VERBOSE, TAG,
|
|
281
|
-
String.format("overrideUrlLoad is called with url: (%s)", url));
|
|
282
|
-
final Message message = (Message)fullscreenMessage.getParent();
|
|
232
|
+
public void onContentLoaded(final Presentable<?> presentable, PresentationContent presentationContent) {
|
|
233
|
+
if (!(presentable.getPresentation() instanceof InAppMessage)) return;
|
|
234
|
+
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
283
235
|
if (message != null) {
|
|
284
|
-
Map data =
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
emitEvent("urlLoaded", data);
|
|
236
|
+
Map<String, String> data =
|
|
237
|
+
RCTAEPMessagingUtil.convertMessageToMap(message);
|
|
238
|
+
emitEvent("onContentLoaded", data);
|
|
288
239
|
}
|
|
289
240
|
}
|
|
290
241
|
|
|
@@ -292,11 +243,6 @@ public final class RCTAEPMessagingModule
|
|
|
292
243
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
293
244
|
public void setMessageSettings(final boolean shouldShowMessage,
|
|
294
245
|
final boolean shouldSaveMessage) {
|
|
295
|
-
MobileCore.log(
|
|
296
|
-
LoggingMode.VERBOSE, TAG,
|
|
297
|
-
String.format(
|
|
298
|
-
"shouldShowMessage is called with message id: %b and shouldSaveMessage: %b",
|
|
299
|
-
shouldShowMessage, shouldSaveMessage));
|
|
300
246
|
this.shouldShowMessage = shouldShowMessage;
|
|
301
247
|
this.shouldSaveMessage = shouldSaveMessage;
|
|
302
248
|
latch.countDown();
|
|
@@ -15,8 +15,8 @@ package com.adobe.marketing.mobile.reactnative.messaging;
|
|
|
15
15
|
import android.app.Activity;
|
|
16
16
|
import com.adobe.marketing.mobile.Message;
|
|
17
17
|
import com.adobe.marketing.mobile.MessagingEdgeEventType;
|
|
18
|
-
import com.adobe.marketing.mobile.messaging.
|
|
19
|
-
import com.adobe.marketing.mobile.messaging.
|
|
18
|
+
import com.adobe.marketing.mobile.messaging.Proposition;
|
|
19
|
+
import com.adobe.marketing.mobile.messaging.PropositionItem;
|
|
20
20
|
import com.adobe.marketing.mobile.messaging.Surface;
|
|
21
21
|
import com.facebook.react.bridge.ReadableArray;
|
|
22
22
|
import com.facebook.react.bridge.ReadableMap;
|
|
@@ -45,13 +45,13 @@ class RCTAEPMessagingUtil {
|
|
|
45
45
|
static MessagingEdgeEventType getEventType(final int eventType) {
|
|
46
46
|
switch (eventType) {
|
|
47
47
|
case 0:
|
|
48
|
-
return MessagingEdgeEventType.
|
|
48
|
+
return MessagingEdgeEventType.DISMISS;
|
|
49
49
|
case 1:
|
|
50
|
-
return MessagingEdgeEventType.
|
|
50
|
+
return MessagingEdgeEventType.INTERACT;
|
|
51
51
|
case 2:
|
|
52
|
-
return MessagingEdgeEventType.
|
|
52
|
+
return MessagingEdgeEventType.TRIGGER;
|
|
53
53
|
case 3:
|
|
54
|
-
return MessagingEdgeEventType.
|
|
54
|
+
return MessagingEdgeEventType.DISPLAY;
|
|
55
55
|
case 4:
|
|
56
56
|
return MessagingEdgeEventType.PUSH_APPLICATION_OPENED;
|
|
57
57
|
case 5:
|
|
@@ -92,18 +92,21 @@ class RCTAEPMessagingUtil {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
static Map
|
|
95
|
-
convertMessagingPropositionToJS(final
|
|
95
|
+
convertMessagingPropositionToJS(final Proposition proposition) {
|
|
96
96
|
Map data = new HashMap<>();
|
|
97
97
|
ArrayList<Map> propositionItems = new ArrayList();
|
|
98
|
-
ListIterator<
|
|
98
|
+
ListIterator<PropositionItem> it =
|
|
99
99
|
proposition.getItems().listIterator();
|
|
100
100
|
|
|
101
101
|
while (it.hasNext()) {
|
|
102
102
|
Map item = new HashMap<>();
|
|
103
|
-
|
|
104
|
-
item.put("
|
|
105
|
-
item.put("
|
|
106
|
-
|
|
103
|
+
PropositionItem prop = it.next();
|
|
104
|
+
item.put("itemId", prop.getItemId());
|
|
105
|
+
item.put("htmlContent", prop.getHtmlContent());
|
|
106
|
+
item.put("jsonContentArray", prop.getJsonContentArrayList());
|
|
107
|
+
item.put("jsonContent", prop.getJsonContentMap());
|
|
108
|
+
item.put("schema", prop.getSchema().toString());
|
|
109
|
+
item.put("itemData", prop.getItemData());
|
|
107
110
|
propositionItems.add(item);
|
|
108
111
|
}
|
|
109
112
|
|
|
@@ -115,11 +118,11 @@ class RCTAEPMessagingUtil {
|
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
static Map convertSurfacePropositions(
|
|
118
|
-
final Map<Surface, List<
|
|
121
|
+
final Map<Surface, List<Proposition>> propositionMap,
|
|
119
122
|
String packageName) {
|
|
120
123
|
Map data = new HashMap<>();
|
|
121
124
|
|
|
122
|
-
for (Map.Entry<Surface, List<
|
|
125
|
+
for (Map.Entry<Surface, List<Proposition>> entry :
|
|
123
126
|
propositionMap.entrySet()) {
|
|
124
127
|
data.put(entry.getKey().getUri().replace(
|
|
125
128
|
"mobileapp://" + packageName + "/", ""),
|
package/dist/Messaging.js
CHANGED
|
@@ -39,7 +39,7 @@ class Messaging {
|
|
|
39
39
|
static getCachedMessages() {
|
|
40
40
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
41
41
|
const messages = yield RCTAEPMessaging.getCachedMessages();
|
|
42
|
-
return messages.map(msg => new Message_1.default(msg));
|
|
42
|
+
return messages.map((msg) => new Message_1.default(msg));
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
@@ -81,13 +81,19 @@ class Messaging {
|
|
|
81
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
82
|
RCTAEPMessaging.setMessageSettings(shouldShowMessage, shouldSaveMessage);
|
|
83
83
|
});
|
|
84
|
-
|
|
84
|
+
if (react_native_1.Platform.OS === 'ios') {
|
|
85
|
+
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); });
|
|
86
|
+
}
|
|
87
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
88
|
+
eventEmitter.addListener('onContentLoaded', (event) => { var _a; return (_a = messagingDelegate === null || messagingDelegate === void 0 ? void 0 : messagingDelegate.onContentLoaded) === null || _a === void 0 ? void 0 : _a.call(messagingDelegate, event.message); });
|
|
89
|
+
}
|
|
85
90
|
RCTAEPMessaging.setMessagingDelegate();
|
|
86
91
|
return () => {
|
|
87
92
|
eventEmitter.removeAllListeners('onDismiss');
|
|
88
93
|
eventEmitter.removeAllListeners('onShow');
|
|
89
94
|
eventEmitter.removeAllListeners('shouldShowMessage');
|
|
90
95
|
eventEmitter.removeAllListeners('urlLoaded');
|
|
96
|
+
eventEmitter.removeAllListeners('onContentLoaded');
|
|
91
97
|
};
|
|
92
98
|
}
|
|
93
99
|
/**
|
package/dist/Messaging.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Messaging.js","sourceRoot":"","sources":["../src/Messaging.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;AAEF,+
|
|
1
|
+
{"version":3,"file":"Messaging.js","sourceRoot":"","sources":["../src/Messaging.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;AAEF,+CAKsB;AACtB,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,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,oBAAoB;QACzB,eAAe,CAAC,oBAAoB,EAAE,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAO,iBAAiB;;YAC5B,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,iBAAiB,EAAE,CAAC;YAC3D,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,iBAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QACjD,CAAC;KAAA;IAED;;;OAGG;IACH,MAAM,CAAO,gBAAgB;;YAC3B,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,gBAAgB,EAAE,CAAC;YACzD,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,iBAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACpD,CAAC;KAAA;IAED;;;;;OAKG;IACH,MAAM,CAAO,0BAA0B,CACrC,QAAkB;;YAElB,OAAO,MAAM,eAAe,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC;QACpE,CAAC;KAAA;IAED;;;OAGG;IACH,MAAM,CAAC,oBAAoB,CAAC,QAA2B;QACrD,iBAAiB,GAAG,QAAQ,CAAC;QAE7B,MAAM,YAAY,GAAG,IAAI,iCAAkB,CAAC,eAAe,CAAC,CAAC;QAE7D,YAAY,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,WAC7C,OAAA,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,MAAM,kEAAG,OAAO,CAAC,CAAA,EAAA,CACrC,CAAC;QAEF,YAAY,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE;;YAChD,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,SAAS,kEAAG,OAAO,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QAEH,YAAY,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC,OAAO,EAAE,EAAE;;YACxD,MAAM,iBAAiB,GACrB,MAAA,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,iBAAiB,kEAAG,OAAO,CAAC,mCAAI,IAAI,CAAC;YAC1D,MAAM,iBAAiB,GACrB,MAAA,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,iBAAiB,kEAAG,OAAO,CAAC,mCAAI,KAAK,CAAC;YAC3D,eAAe,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC;QAEH,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;YACzB,YAAY,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,WAC9C,OAAA,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,SAAS,kEAAG,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA,EAAA,CACzD,CAAC;SACH;QAED,IAAI,uBAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;YAC7B,YAAY,CAAC,WAAW,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,WACpD,OAAA,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,eAAe,kEAAG,KAAK,CAAC,OAAO,CAAC,CAAA,EAAA,CACpD,CAAC;SACH;QAED,eAAe,CAAC,oBAAoB,EAAE,CAAC;QAEvC,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;YAC7C,YAAY,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;YAC1C,YAAY,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;YACrD,YAAY,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;YAC7C,YAAY,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;QACrD,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,kBAAkB,CACvB,iBAA0B,EAC1B,iBAA0B;QAE1B,eAAe,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,6BAA6B,CAAC,QAAkB;QACrD,eAAe,CAAC,6BAA6B,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;CACF;AAED,kBAAe,SAAS,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ import Messaging from './Messaging';
|
|
|
2
2
|
import Message from './models/Message';
|
|
3
3
|
import { MessagingDelegate } from './models/MessagingDelegate';
|
|
4
4
|
import MessagingEdgeEventType from './models/MessagingEdgeEventType';
|
|
5
|
-
|
|
5
|
+
import { MessagingProposition } from './models/MessagingProposition';
|
|
6
|
+
import { MessagingPropositionItem } from './models/MessagingPropositionItem';
|
|
7
|
+
export { Messaging, Message, MessagingDelegate, MessagingEdgeEventType, MessagingProposition, MessagingPropositionItem };
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ 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.MessagingEdgeEventType = exports.Message = exports.Messaging = void 0;
|
|
14
|
+
exports.MessagingProposition = exports.MessagingEdgeEventType = exports.Message = exports.Messaging = void 0;
|
|
15
15
|
const tslib_1 = require("tslib");
|
|
16
16
|
const Messaging_1 = tslib_1.__importDefault(require("./Messaging"));
|
|
17
17
|
exports.Messaging = Messaging_1.default;
|
|
@@ -19,4 +19,6 @@ const Message_1 = tslib_1.__importDefault(require("./models/Message"));
|
|
|
19
19
|
exports.Message = Message_1.default;
|
|
20
20
|
const MessagingEdgeEventType_1 = tslib_1.__importDefault(require("./models/MessagingEdgeEventType"));
|
|
21
21
|
exports.MessagingEdgeEventType = MessagingEdgeEventType_1.default;
|
|
22
|
+
const MessagingProposition_1 = require("./models/MessagingProposition");
|
|
23
|
+
Object.defineProperty(exports, "MessagingProposition", { enumerable: true, get: function () { return MessagingProposition_1.MessagingProposition; } });
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;;AAEF,oEAAoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;;AAEF,oEAAoC;AAQlC,oBARK,mBAAS,CAQL;AAPX,uEAAuC;AAQrC,kBARK,iBAAO,CAQL;AANT,qGAAqE;AAQnE,iCARK,gCAAsB,CAQL;AAPxB,wEAAqE;AAQnE,qGARO,2CAAoB,OAQP"}
|
package/dist/models/Message.d.ts
CHANGED
|
@@ -29,13 +29,6 @@ declare class Message {
|
|
|
29
29
|
* @param {MessagingEdgeEventType} eventType: the MessagingEdgeEventType to be used for the ensuing Edge Event
|
|
30
30
|
*/
|
|
31
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
32
|
/**
|
|
40
33
|
* Clears the cached reference to the Message object.
|
|
41
34
|
* This function must be called if Message was saved by calling "MessagingDelegate.shouldSaveMessage" but no longer needed.
|
package/dist/models/Message.js
CHANGED
|
@@ -51,15 +51,6 @@ class Message {
|
|
|
51
51
|
track(interaction, eventType) {
|
|
52
52
|
RCTAEPMessaging.track(this.id, interaction, eventType);
|
|
53
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
54
|
/**
|
|
64
55
|
* Clears the cached reference to the Message object.
|
|
65
56
|
* This function must be called if Message was saved by calling "MessagingDelegate.shouldSaveMessage" but no longer needed.
|
|
@@ -1 +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
|
|
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;;;;OAIG;IACH,KAAK;QACH,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;CACF;AAED,kBAAe,OAAO,CAAC"}
|
|
@@ -22,9 +22,14 @@ export interface MessagingDelegate {
|
|
|
22
22
|
*/
|
|
23
23
|
shouldShowMessage?(message: Message): boolean;
|
|
24
24
|
/**
|
|
25
|
-
* Called when message loads a URL
|
|
25
|
+
* IOS Only - Called when message loads a URL
|
|
26
26
|
* @param {string} url: the URL being loaded by the message
|
|
27
27
|
* @param {Message} message: the Message loading a URL
|
|
28
28
|
*/
|
|
29
29
|
urlLoaded?(url: string, message: Message): void;
|
|
30
|
+
/**
|
|
31
|
+
* Android Only - Called when message loads
|
|
32
|
+
* @param {Message} message: the Message loaded
|
|
33
|
+
*/
|
|
34
|
+
onContentLoaded?(message: Message): void;
|
|
30
35
|
}
|
|
@@ -13,10 +13,10 @@ governing permissions and limitations under the License.
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
var MessagingEdgeEventType;
|
|
15
15
|
(function (MessagingEdgeEventType) {
|
|
16
|
-
MessagingEdgeEventType[MessagingEdgeEventType["
|
|
17
|
-
MessagingEdgeEventType[MessagingEdgeEventType["
|
|
18
|
-
MessagingEdgeEventType[MessagingEdgeEventType["
|
|
19
|
-
MessagingEdgeEventType[MessagingEdgeEventType["
|
|
16
|
+
MessagingEdgeEventType[MessagingEdgeEventType["DISMISS"] = 0] = "DISMISS";
|
|
17
|
+
MessagingEdgeEventType[MessagingEdgeEventType["INTERACT"] = 1] = "INTERACT";
|
|
18
|
+
MessagingEdgeEventType[MessagingEdgeEventType["TRIGGER"] = 2] = "TRIGGER";
|
|
19
|
+
MessagingEdgeEventType[MessagingEdgeEventType["DISPLAY"] = 3] = "DISPLAY";
|
|
20
20
|
MessagingEdgeEventType[MessagingEdgeEventType["PUSH_APPLICATION_OPENED"] = 4] = "PUSH_APPLICATION_OPENED";
|
|
21
21
|
MessagingEdgeEventType[MessagingEdgeEventType["PUSH_CUSTOM_ACTION"] = 5] = "PUSH_CUSTOM_ACTION";
|
|
22
22
|
})(MessagingEdgeEventType || (MessagingEdgeEventType = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessagingEdgeEventType.js","sourceRoot":"","sources":["../../src/models/MessagingEdgeEventType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;AAEF,IAAK,sBAOJ;AAPD,WAAK,sBAAsB;IACvB,
|
|
1
|
+
{"version":3,"file":"MessagingEdgeEventType.js","sourceRoot":"","sources":["../../src/models/MessagingEdgeEventType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;AAEF,IAAK,sBAOJ;AAPD,WAAK,sBAAsB;IACvB,yEAAW,CAAA;IACX,2EAAY,CAAA;IACZ,yEAAW,CAAA;IACX,yEAAW,CAAA;IACX,yGAA2B,CAAA;IAC3B,+FAAsB,CAAA;AAC1B,CAAC,EAPI,sBAAsB,KAAtB,sBAAsB,QAO1B;AAAA,CAAC;AAEF,kBAAe,sBAAsB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export interface MessagingPropositionItem {
|
|
2
|
+
htmlContent?: string;
|
|
3
|
+
jsonArrayContent?: string;
|
|
4
|
+
jsonContent?: string;
|
|
5
|
+
itemData?: Record<string, any>;
|
|
3
6
|
schema: string;
|
|
4
7
|
uniqueId: string;
|
|
5
|
-
constructor(uniqueId: string, schema: string, content: string);
|
|
6
8
|
}
|
|
@@ -11,13 +11,4 @@
|
|
|
11
11
|
language governing permissions and limitations under the License.
|
|
12
12
|
*/
|
|
13
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
14
|
//# sourceMappingURL=MessagingPropositionItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessagingPropositionItem.js","sourceRoot":"","sources":["../../src/models/MessagingPropositionItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE
|
|
1
|
+
{"version":3,"file":"MessagingPropositionItem.js","sourceRoot":"","sources":["../../src/models/MessagingPropositionItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE"}
|
|
@@ -143,23 +143,6 @@ public class RCTAEPMessaging: RCTEventEmitter, MessagingDelegate {
|
|
|
143
143
|
reject(Constants.CACHE_MISS, nil, nil)
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
@objc
|
|
147
|
-
func handleJavascriptMessage(
|
|
148
|
-
_ id: String,
|
|
149
|
-
withName name: String,
|
|
150
|
-
withResolver resolve: @escaping RCTPromiseResolveBlock,
|
|
151
|
-
withRejecter reject: @escaping RCTPromiseRejectBlock
|
|
152
|
-
) {
|
|
153
|
-
let msg = messageCache[id]
|
|
154
|
-
if msg != nil {
|
|
155
|
-
msg!.handleJavascriptMessage(name) { content in
|
|
156
|
-
resolve(content)
|
|
157
|
-
return
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
reject(Constants.CACHE_MISS, nil, nil)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
146
|
@objc
|
|
164
147
|
func setAutoTrack(
|
|
165
148
|
_ id: String,
|
|
@@ -205,7 +188,7 @@ public class RCTAEPMessaging: RCTEventEmitter, MessagingDelegate {
|
|
|
205
188
|
let msg = messageCache[id]
|
|
206
189
|
let eventType =
|
|
207
190
|
MessagingEdgeEventType.init(rawValue: eventType)
|
|
208
|
-
|
|
191
|
+
?? MessagingEdgeEventType.dismiss
|
|
209
192
|
if msg != nil {
|
|
210
193
|
msg!.track(interaction, withEdgeEventType: eventType)
|
|
211
194
|
resolve(nil)
|
|
@@ -19,7 +19,7 @@ public class RCTAEPMessagingDataBridge: NSObject {
|
|
|
19
19
|
]
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
static func transformPropositionDict(dict: [Surface: [
|
|
22
|
+
static func transformPropositionDict(dict: [Surface: [Proposition]]) -> [String: [Any]]
|
|
23
23
|
{
|
|
24
24
|
let bundleID = "mobileapp://" + Bundle.main.bundleIdentifier! + "/"
|
|
25
25
|
return dict.reduce(into: [:]) { result, element in
|
|
@@ -28,12 +28,18 @@ public class RCTAEPMessagingDataBridge: NSObject {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
static func transformToProposition(proposition:
|
|
31
|
+
static func transformToProposition(proposition: Proposition) -> [String: Any?] {
|
|
32
32
|
return [
|
|
33
|
-
"scope": proposition.scope,
|
|
33
|
+
"scope": proposition.scope,
|
|
34
|
+
"uniqueId": proposition.uniqueId,
|
|
34
35
|
"items": proposition.items.map({ item in
|
|
35
36
|
[
|
|
36
|
-
"
|
|
37
|
+
"htmlContent": item.htmlContent,
|
|
38
|
+
"jsonContentArray": item.jsonContentArray,
|
|
39
|
+
"jsonContent": item.jsonContentDictionary,
|
|
40
|
+
"itemData": item.itemData as Any?,
|
|
41
|
+
"schema": item.schema,
|
|
42
|
+
"itemId": item.itemId
|
|
37
43
|
]
|
|
38
44
|
}),
|
|
39
45
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/react-native-aepmessaging",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Adobe Experience Platform support for React Native apps.",
|
|
5
5
|
"homepage": "https://developer.adobe.com/client-sdks/documentation/",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"name": "Adobe Experience Platform SDK Team"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@adobe/react-native-aepcore": "^
|
|
31
|
-
"@adobe/react-native-aepedge": "^
|
|
32
|
-
"@adobe/react-native-aepedgeidentity": "^
|
|
30
|
+
"@adobe/react-native-aepcore": "^6.0.0",
|
|
31
|
+
"@adobe/react-native-aepedge": "^6.0.0",
|
|
32
|
+
"@adobe/react-native-aepedgeidentity": "^6.0.0",
|
|
33
33
|
"react-native": ">=0.60.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"installConfig": {
|
|
39
39
|
"hoistingLimits": "dependencies"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "7df5d257041d7bc1072177e21ff4286cf04773f6"
|
|
42
42
|
}
|
package/src/Messaging.ts
CHANGED
|
@@ -10,7 +10,12 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
NativeModules,
|
|
15
|
+
NativeEventEmitter,
|
|
16
|
+
NativeModule,
|
|
17
|
+
Platform
|
|
18
|
+
} from 'react-native';
|
|
14
19
|
import Message from './models/Message';
|
|
15
20
|
import { MessagingDelegate } from './models/MessagingDelegate';
|
|
16
21
|
import { MessagingProposition } from './models/MessagingProposition';
|
|
@@ -61,7 +66,7 @@ class Messaging {
|
|
|
61
66
|
*/
|
|
62
67
|
static async getCachedMessages(): Promise<Message[]> {
|
|
63
68
|
const messages = await RCTAEPMessaging.getCachedMessages();
|
|
64
|
-
return messages.map(msg => new Message(msg));
|
|
69
|
+
return messages.map((msg) => new Message(msg));
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
/**
|
|
@@ -110,9 +115,17 @@ class Messaging {
|
|
|
110
115
|
RCTAEPMessaging.setMessageSettings(shouldShowMessage, shouldSaveMessage);
|
|
111
116
|
});
|
|
112
117
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
118
|
+
if (Platform.OS === 'ios') {
|
|
119
|
+
eventEmitter.addListener('urlLoaded', (event) =>
|
|
120
|
+
messagingDelegate?.urlLoaded?.(event.url, event.message)
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (Platform.OS === 'android') {
|
|
125
|
+
eventEmitter.addListener('onContentLoaded', (event) =>
|
|
126
|
+
messagingDelegate?.onContentLoaded?.(event.message)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
116
129
|
|
|
117
130
|
RCTAEPMessaging.setMessagingDelegate();
|
|
118
131
|
|
|
@@ -121,6 +134,7 @@ class Messaging {
|
|
|
121
134
|
eventEmitter.removeAllListeners('onShow');
|
|
122
135
|
eventEmitter.removeAllListeners('shouldShowMessage');
|
|
123
136
|
eventEmitter.removeAllListeners('urlLoaded');
|
|
137
|
+
eventEmitter.removeAllListeners('onContentLoaded');
|
|
124
138
|
};
|
|
125
139
|
}
|
|
126
140
|
|
|
@@ -131,7 +145,10 @@ class Messaging {
|
|
|
131
145
|
* @param shouldShowMessage Whether or not a message should be displayed
|
|
132
146
|
* @param shouldSaveMessage Whether or not a message should be cached
|
|
133
147
|
*/
|
|
134
|
-
static setMessageSettings(
|
|
148
|
+
static setMessageSettings(
|
|
149
|
+
shouldShowMessage: boolean,
|
|
150
|
+
shouldSaveMessage: boolean
|
|
151
|
+
) {
|
|
135
152
|
RCTAEPMessaging.setMessageSettings(shouldShowMessage, shouldSaveMessage);
|
|
136
153
|
}
|
|
137
154
|
|
package/src/index.ts
CHANGED
|
@@ -14,5 +14,14 @@ import Messaging from './Messaging';
|
|
|
14
14
|
import Message from './models/Message';
|
|
15
15
|
import { MessagingDelegate } from './models/MessagingDelegate';
|
|
16
16
|
import MessagingEdgeEventType from './models/MessagingEdgeEventType';
|
|
17
|
+
import { MessagingProposition } from './models/MessagingProposition';
|
|
18
|
+
import { MessagingPropositionItem } from './models/MessagingPropositionItem';
|
|
17
19
|
|
|
18
|
-
export {
|
|
20
|
+
export {
|
|
21
|
+
Messaging,
|
|
22
|
+
Message,
|
|
23
|
+
MessagingDelegate,
|
|
24
|
+
MessagingEdgeEventType,
|
|
25
|
+
MessagingProposition,
|
|
26
|
+
MessagingPropositionItem
|
|
27
|
+
};
|
package/src/models/Message.ts
CHANGED
|
@@ -59,18 +59,6 @@ class Message {
|
|
|
59
59
|
RCTAEPMessaging.track(this.id, interaction, eventType);
|
|
60
60
|
}
|
|
61
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(
|
|
70
|
-
RCTAEPMessaging.handleJavascriptMessage(this.id, name)
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
62
|
/**
|
|
75
63
|
* Clears the cached reference to the Message object.
|
|
76
64
|
* This function must be called if Message was saved by calling "MessagingDelegate.shouldSaveMessage" but no longer needed.
|
|
@@ -39,9 +39,15 @@ export interface MessagingDelegate {
|
|
|
39
39
|
shouldShowMessage?(message: Message): boolean;
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Called when message loads a URL
|
|
42
|
+
* IOS Only - Called when message loads a URL
|
|
43
43
|
* @param {string} url: the URL being loaded by the message
|
|
44
44
|
* @param {Message} message: the Message loading a URL
|
|
45
45
|
*/
|
|
46
46
|
urlLoaded?(url: string, message: Message): void;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Android Only - Called when message loads
|
|
50
|
+
* @param {Message} message: the Message loaded
|
|
51
|
+
*/
|
|
52
|
+
onContentLoaded?( message: Message): void;
|
|
47
53
|
}
|
|
@@ -11,10 +11,10 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
enum MessagingEdgeEventType {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
DISMISS = 0,
|
|
15
|
+
INTERACT = 1,
|
|
16
|
+
TRIGGER = 2,
|
|
17
|
+
DISPLAY = 3,
|
|
18
18
|
PUSH_APPLICATION_OPENED = 4,
|
|
19
19
|
PUSH_CUSTOM_ACTION = 5
|
|
20
20
|
};
|
|
@@ -10,14 +10,11 @@
|
|
|
10
10
|
language governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.schema = schema;
|
|
21
|
-
this.content = content;
|
|
22
|
-
}
|
|
13
|
+
export interface MessagingPropositionItem {
|
|
14
|
+
htmlContent?: string;
|
|
15
|
+
jsonArrayContent?: string;
|
|
16
|
+
jsonContent?: string;
|
|
17
|
+
itemData?: Record<string, any>;
|
|
18
|
+
schema: string;
|
|
19
|
+
uniqueId: string;
|
|
23
20
|
}
|