@adobe/react-native-aepmessaging 5.0.0 → 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/.babelrc +1 -1
- package/RCTAEPMessaging.podspec +26 -8
- package/README.md +93 -10
- package/android/build.gradle +84 -22
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +0 -2
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingModule.java +215 -202
- package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingPackage.java +27 -25
- package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingUtil.java +134 -0
- package/dist/Messaging.d.ts +62 -0
- package/dist/Messaging.js +118 -0
- package/dist/Messaging.js.map +1 -0
- package/{js → dist}/index.d.ts +3 -1
- package/{js → dist}/index.js +4 -2
- package/dist/index.js.map +1 -0
- package/dist/models/Message.d.ts +39 -0
- package/dist/models/Message.js +64 -0
- package/dist/models/Message.js.map +1 -0
- package/dist/models/MessagingDelegate.d.ts +35 -0
- package/{js → dist}/models/MessagingDelegate.js +1 -1
- package/dist/models/MessagingDelegate.js.map +1 -0
- package/{js → dist}/models/MessagingEdgeEventType.d.ts +4 -4
- package/{js → dist}/models/MessagingEdgeEventType.js +5 -5
- package/dist/models/MessagingEdgeEventType.js.map +1 -0
- package/dist/models/MessagingProposition.d.ts +8 -0
- package/dist/models/MessagingProposition.js +24 -0
- package/dist/models/MessagingProposition.js.map +1 -0
- package/dist/models/MessagingPropositionItem.d.ts +8 -0
- package/dist/models/MessagingPropositionItem.js +14 -0
- package/dist/models/MessagingPropositionItem.js.map +1 -0
- package/ios/src/RCTAEPMessaging-Bridging-Header.h +15 -0
- package/ios/src/RCTAEPMessaging.mm +50 -0
- package/ios/src/RCTAEPMessaging.swift +266 -0
- package/ios/src/RCTAEPMessagingConstants.swift +22 -0
- package/ios/src/RCTAEPMessagingDataBridge.swift +47 -0
- package/package.json +6 -6
- package/src/Messaging.ts +164 -0
- package/{ts → src}/index.ts +11 -2
- package/src/models/Message.ts +72 -0
- package/src/models/MessagingDelegate.ts +53 -0
- package/{ts → src}/models/MessagingEdgeEventType.ts +5 -5
- package/src/models/MessagingProposition.ts +32 -0
- package/src/models/MessagingPropositionItem.ts +20 -0
- package/tsconfig.json +2 -2
- package/ios/RCTAEPMessaging.xcodeproj/project.pbxproj +0 -304
- package/ios/src/RCTAEPMessaging.h +0 -20
- package/ios/src/RCTAEPMessaging.m +0 -196
- package/js/Messaging.d.ts +0 -32
- package/js/Messaging.js +0 -80
- package/js/Messaging.js.map +0 -1
- package/js/index.js.map +0 -1
- package/js/models/Message.d.ts +0 -43
- package/js/models/Message.js +0 -80
- package/js/models/Message.js.map +0 -1
- package/js/models/MessagingDelegate.d.ts +0 -25
- package/js/models/MessagingDelegate.js.map +0 -1
- package/js/models/MessagingEdgeEventType.js.map +0 -1
- package/ts/Messaging.ts +0 -99
- package/ts/models/Message.ts +0 -82
- package/ts/models/MessagingDelegate.ts +0 -41
|
@@ -1,253 +1,266 @@
|
|
|
1
1
|
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
you may not use this file except in compliance with the License.
|
|
5
|
-
of the License at
|
|
6
|
-
Unless required by applicable law
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the
|
|
4
|
+
"License"); you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
|
|
7
|
+
or agreed to in writing, software distributed under the License is
|
|
8
|
+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
|
|
9
|
+
ANY KIND, either express or implied. See the License for the specific
|
|
10
|
+
language governing permissions and limitations under the License.
|
|
10
11
|
*/
|
|
11
12
|
package com.adobe.marketing.mobile.reactnative.messaging;
|
|
12
13
|
|
|
13
|
-
import
|
|
14
|
-
import com.adobe.marketing.mobile.LoggingMode;
|
|
15
|
-
|
|
16
|
-
import static com.adobe.marketing.mobile.LoggingMode.DEBUG;
|
|
17
|
-
import static com.adobe.marketing.mobile.LoggingMode.VERBOSE;
|
|
14
|
+
import android.app.Activity;
|
|
18
15
|
|
|
19
|
-
import
|
|
16
|
+
import androidx.annotation.NonNull;
|
|
20
17
|
|
|
18
|
+
import com.adobe.marketing.mobile.AdobeCallback;
|
|
19
|
+
import com.adobe.marketing.mobile.AdobeCallbackWithError;
|
|
20
|
+
import com.adobe.marketing.mobile.AdobeError;
|
|
21
|
+
import com.adobe.marketing.mobile.LoggingMode;
|
|
21
22
|
import com.adobe.marketing.mobile.Message;
|
|
22
23
|
import com.adobe.marketing.mobile.Messaging;
|
|
23
24
|
import com.adobe.marketing.mobile.MessagingEdgeEventType;
|
|
24
25
|
import com.adobe.marketing.mobile.MobileCore;
|
|
25
|
-
import com.adobe.marketing.mobile.
|
|
26
|
-
import com.adobe.marketing.mobile.
|
|
26
|
+
import com.adobe.marketing.mobile.messaging.MessagingUtils;
|
|
27
|
+
import com.adobe.marketing.mobile.messaging.Proposition;
|
|
28
|
+
import com.adobe.marketing.mobile.messaging.Surface;
|
|
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;
|
|
30
36
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
31
37
|
import com.facebook.react.bridge.ReactMethod;
|
|
38
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
32
39
|
import com.facebook.react.bridge.WritableMap;
|
|
33
40
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
34
|
-
|
|
35
41
|
import java.util.HashMap;
|
|
42
|
+
import java.util.List;
|
|
36
43
|
import java.util.Map;
|
|
37
44
|
import java.util.concurrent.CountDownLatch;
|
|
38
45
|
|
|
39
|
-
public final class RCTAEPMessagingModule
|
|
40
|
-
|
|
41
|
-
private static final String TAG = "RCTAEPMessagingModule";
|
|
42
|
-
private final Map<String, Message> messageCache;
|
|
43
|
-
private final ReactApplicationContext reactContext;
|
|
44
|
-
private boolean shouldSaveMessage;
|
|
45
|
-
private boolean shouldShowMessage;
|
|
46
|
-
private CountDownLatch latch = new CountDownLatch(1);
|
|
47
|
-
|
|
48
|
-
public RCTAEPMessagingModule(ReactApplicationContext reactContext) {
|
|
49
|
-
super(reactContext);
|
|
50
|
-
this.reactContext = reactContext;
|
|
51
|
-
this.messageCache = new HashMap<>();
|
|
52
|
-
this.shouldShowMessage = false;
|
|
53
|
-
this.shouldSaveMessage = false;
|
|
54
|
-
}
|
|
46
|
+
public final class RCTAEPMessagingModule
|
|
47
|
+
extends ReactContextBaseJavaModule implements PresentationDelegate {
|
|
55
48
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
private static final String TAG = "RCTAEPMessagingModule";
|
|
50
|
+
private final Map<String, Message> messageCache = new HashMap<>();
|
|
51
|
+
private final ReactApplicationContext reactContext;
|
|
52
|
+
private boolean shouldSaveMessage = false;
|
|
53
|
+
private boolean shouldShowMessage = false;
|
|
54
|
+
private CountDownLatch latch = new CountDownLatch(1);
|
|
55
|
+
private Message latestMessage = null;
|
|
56
|
+
|
|
57
|
+
public RCTAEPMessagingModule(ReactApplicationContext reactContext) {
|
|
58
|
+
super(reactContext);
|
|
59
|
+
this.reactContext = reactContext;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Override
|
|
63
|
+
public String getName() {
|
|
64
|
+
return "AEPMessaging";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Required for rn built in EventEmitter Calls.
|
|
68
|
+
@ReactMethod
|
|
69
|
+
public void addListener(String eventName) {}
|
|
60
70
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
public void addListener(String eventName) {}
|
|
71
|
+
@ReactMethod
|
|
72
|
+
public void removeListeners(Integer count) {}
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
@ReactMethod
|
|
75
|
+
public void extensionVersion(final Promise promise) {
|
|
76
|
+
promise.resolve(Messaging.extensionVersion());
|
|
77
|
+
}
|
|
67
78
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
79
|
+
@ReactMethod
|
|
80
|
+
public void getCachedMessages(final Promise promise) {
|
|
81
|
+
promise.resolve(
|
|
82
|
+
RCTAEPMessagingUtil.convertMessagesToJS(this.messageCache.values()));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@ReactMethod
|
|
86
|
+
public void getLatestMessage(final Promise promise) {
|
|
87
|
+
promise.resolve(this.latestMessage);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@ReactMethod
|
|
91
|
+
public void getPropositionsForSurfaces(ReadableArray surfaces,
|
|
92
|
+
final Promise promise) {
|
|
93
|
+
String bundleId = this.reactContext.getPackageName();
|
|
94
|
+
Messaging.getPropositionsForSurfaces(
|
|
95
|
+
RCTAEPMessagingUtil.convertSurfaces(surfaces),
|
|
96
|
+
new AdobeCallbackWithError<Map<Surface, List<Proposition>>>() {
|
|
97
|
+
@Override
|
|
98
|
+
public void fail(final AdobeError adobeError) {
|
|
99
|
+
promise.reject(adobeError.getErrorName(),
|
|
100
|
+
"Unable to get Propositions");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@Override
|
|
104
|
+
public void call(
|
|
105
|
+
Map<Surface, List<Proposition>> propositionsMap) {
|
|
106
|
+
promise.resolve(RCTAEPMessagingUtil.convertSurfacePropositions(
|
|
107
|
+
propositionsMap, bundleId));
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@ReactMethod
|
|
113
|
+
public void refreshInAppMessages() {
|
|
114
|
+
Messaging.refreshInAppMessages();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@ReactMethod
|
|
118
|
+
public void setMessagingDelegate() {
|
|
119
|
+
ServiceProvider.getInstance().getUIService().setPresentationDelegate(this);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@ReactMethod
|
|
123
|
+
public void updatePropositionsForSurfaces(ReadableArray surfaces) {
|
|
124
|
+
Messaging.updatePropositionsForSurfaces(
|
|
125
|
+
RCTAEPMessagingUtil.convertSurfaces(surfaces));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Message Methods
|
|
129
|
+
|
|
130
|
+
@ReactMethod
|
|
131
|
+
public void clear(final String messageId) {
|
|
132
|
+
if (messageId != null) {
|
|
133
|
+
messageCache.remove(messageId);
|
|
72
134
|
}
|
|
135
|
+
}
|
|
73
136
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
137
|
+
@ReactMethod
|
|
138
|
+
public void dismiss(final String messageId) {
|
|
139
|
+
if (messageId != null && messageCache.get(messageId) != null) {
|
|
140
|
+
messageCache.get(messageId).dismiss();
|
|
78
141
|
}
|
|
142
|
+
}
|
|
79
143
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
144
|
+
@ReactMethod
|
|
145
|
+
public void setAutoTrack(final String messageId, final boolean autoTrack) {
|
|
146
|
+
if (messageId != null && messageCache.get(messageId) != null) {
|
|
147
|
+
messageCache.get(messageId).setAutoTrack(autoTrack);
|
|
84
148
|
}
|
|
149
|
+
}
|
|
85
150
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
messageCache.get(messageId).show();
|
|
91
|
-
}
|
|
151
|
+
@ReactMethod
|
|
152
|
+
public void show(final String messageId) {
|
|
153
|
+
if (messageId != null && messageCache.get(messageId) != null) {
|
|
154
|
+
messageCache.get(messageId).show();
|
|
92
155
|
}
|
|
156
|
+
}
|
|
93
157
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
158
|
+
@ReactMethod
|
|
159
|
+
public void track(final String messageId, final String interaction,
|
|
160
|
+
final int eventType) {
|
|
161
|
+
if (messageId != null && messageCache.get(messageId) != null) {
|
|
162
|
+
MessagingEdgeEventType edgeEventType =
|
|
163
|
+
RCTAEPMessagingUtil.getEventType(eventType);
|
|
164
|
+
if (edgeEventType != null) {
|
|
165
|
+
messageCache.get(messageId).track(interaction, edgeEventType);
|
|
166
|
+
}
|
|
100
167
|
}
|
|
168
|
+
}
|
|
101
169
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
case 1:
|
|
112
|
-
edgeEventType = MessagingEdgeEventType.IN_APP_INTERACT;
|
|
113
|
-
break;
|
|
114
|
-
case 2:
|
|
115
|
-
edgeEventType = MessagingEdgeEventType.IN_APP_TRIGGER;
|
|
116
|
-
break;
|
|
117
|
-
case 3:
|
|
118
|
-
edgeEventType = MessagingEdgeEventType.IN_APP_DISPLAY;
|
|
119
|
-
break;
|
|
120
|
-
case 4:
|
|
121
|
-
edgeEventType = MessagingEdgeEventType.PUSH_APPLICATION_OPENED;
|
|
122
|
-
break;
|
|
123
|
-
case 5:
|
|
124
|
-
edgeEventType = MessagingEdgeEventType.PUSH_CUSTOM_ACTION;
|
|
125
|
-
break;
|
|
126
|
-
default:
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
if (edgeEventType != null) {
|
|
130
|
-
messageCache.get(messageId).track(interaction, edgeEventType);
|
|
131
|
-
} else {
|
|
132
|
-
MobileCore.log(DEBUG, TAG, String.format("Unable to track interaction (%s) because edgeEventType (%d) is invalid ", interaction, eventType));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
170
|
+
// Messaging Delegate functions
|
|
171
|
+
@Override
|
|
172
|
+
public void onShow(final Presentable<?> presentable) {
|
|
173
|
+
if (!(presentable.getPresentation() instanceof InAppMessage)) return;
|
|
174
|
+
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
175
|
+
if (message != null) {
|
|
176
|
+
Map<String, String> data =
|
|
177
|
+
RCTAEPMessagingUtil.convertMessageToMap(message);
|
|
178
|
+
emitEvent("onShow", data);
|
|
135
179
|
}
|
|
180
|
+
}
|
|
136
181
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
promise.resolve(s);
|
|
146
|
-
} else {
|
|
147
|
-
promise.reject("error", "error in handling javascriptMessage " + messageName);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
182
|
+
@Override
|
|
183
|
+
public void onDismiss(final Presentable<?> presentable) {
|
|
184
|
+
if (!(presentable.getPresentation() instanceof InAppMessage)) return;
|
|
185
|
+
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
186
|
+
if (message != null) {
|
|
187
|
+
Map<String, String> data =
|
|
188
|
+
RCTAEPMessagingUtil.convertMessageToMap(message);
|
|
189
|
+
emitEvent("onDismiss", data);
|
|
152
190
|
}
|
|
191
|
+
}
|
|
153
192
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
193
|
+
@Override
|
|
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);
|
|
160
201
|
}
|
|
202
|
+
}
|
|
161
203
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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);
|
|
208
|
+
if (message != null) {
|
|
209
|
+
Map<String, String> data =
|
|
210
|
+
RCTAEPMessagingUtil.convertMessageToMap(message);
|
|
211
|
+
emitEvent("shouldShowMessage", data);
|
|
212
|
+
// Latch stops the thread until the shouldShowMessage value is received
|
|
213
|
+
// from the JS side on thread dedicated to run JS code. The function
|
|
214
|
+
// called from JS that resumes the thread is "shouldShowMessage".
|
|
215
|
+
try {
|
|
216
|
+
latch.await();
|
|
217
|
+
} catch (final InterruptedException e) {
|
|
218
|
+
}
|
|
168
219
|
}
|
|
169
220
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
MobileCore.log(VERBOSE, TAG, String.format("shouldShowMessage is called with message id: %b and shouldSaveMessage: %b", shouldShowMessage, shouldSaveMessage));
|
|
173
|
-
this.shouldShowMessage = shouldShowMessage;
|
|
174
|
-
this.shouldSaveMessage = shouldSaveMessage;
|
|
175
|
-
latch.countDown();
|
|
221
|
+
if (shouldShowMessage) {
|
|
222
|
+
this.latestMessage = message;
|
|
176
223
|
}
|
|
177
224
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
public void onShow(final FullscreenMessage fullscreenMessage) {
|
|
181
|
-
MobileCore.log(VERBOSE, TAG, "onShow is called");
|
|
182
|
-
final Message message = (Message) fullscreenMessage.getParent();
|
|
183
|
-
if (message != null) {
|
|
184
|
-
Map<String, String> data = new HashMap<>();
|
|
185
|
-
data.put("id", message.getId());
|
|
186
|
-
data.put("autoTrack", String.valueOf(message.getAutoTrack()));
|
|
187
|
-
emitEvent("onShow", data);
|
|
188
|
-
}
|
|
225
|
+
if (shouldSaveMessage) {
|
|
226
|
+
messageCache.put(message.getId(), message);
|
|
189
227
|
}
|
|
190
228
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
229
|
+
return shouldShowMessage;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public void onContentLoaded(final Presentable<?> presentable, PresentationContent presentationContent) {
|
|
233
|
+
if (!(presentable.getPresentation() instanceof InAppMessage)) return;
|
|
234
|
+
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
235
|
+
if (message != null) {
|
|
236
|
+
Map<String, String> data =
|
|
237
|
+
RCTAEPMessagingUtil.convertMessageToMap(message);
|
|
238
|
+
emitEvent("onContentLoaded", data);
|
|
201
239
|
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Messaging Delegate Callback
|
|
243
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
244
|
+
public void setMessageSettings(final boolean shouldShowMessage,
|
|
245
|
+
final boolean shouldSaveMessage) {
|
|
246
|
+
this.shouldShowMessage = shouldShowMessage;
|
|
247
|
+
this.shouldSaveMessage = shouldSaveMessage;
|
|
248
|
+
latch.countDown();
|
|
249
|
+
}
|
|
202
250
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
MobileCore.log(VERBOSE, TAG, "shouldShowMessage: Thread is locked.");
|
|
214
|
-
try {
|
|
215
|
-
latch.await();
|
|
216
|
-
} catch (final InterruptedException e) {
|
|
217
|
-
MobileCore.log(LoggingMode.ERROR, TAG, String.format("CountDownLatch await Interrupted: (%s)", e.getLocalizedMessage()));
|
|
218
|
-
}
|
|
219
|
-
MobileCore.log(VERBOSE, TAG, "shouldShowMessage: Thread is resumed.");
|
|
220
|
-
if (shouldSaveMessage) {
|
|
221
|
-
messageCache.put(message.getId(), message);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return shouldShowMessage;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
@Override
|
|
228
|
-
public void urlLoaded(String url, FullscreenMessage fullscreenMessage) {
|
|
229
|
-
MobileCore.log(VERBOSE, TAG, String.format("overrideUrlLoad is called with url: (%s)", url));
|
|
230
|
-
final Message message = (Message) fullscreenMessage.getParent();
|
|
231
|
-
if (message != null) {
|
|
232
|
-
Map<String, String> data = new HashMap<>();
|
|
233
|
-
data.put("id", message.getId());
|
|
234
|
-
data.put("autoTrack", String.valueOf(message.getAutoTrack()));
|
|
235
|
-
data.put("url", url);
|
|
236
|
-
emitEvent("urlLoaded", data);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Emits an event along with data to be handled by the Javascript
|
|
242
|
-
*
|
|
243
|
-
* @param name event name
|
|
244
|
-
* @param data data sent along with event
|
|
245
|
-
*/
|
|
246
|
-
private void emitEvent(final String name, final Map<String, String> data) {
|
|
247
|
-
WritableMap eventData = Arguments.createMap();
|
|
248
|
-
for (final Map.Entry<String, String> entry : data.entrySet()) {
|
|
249
|
-
eventData.putString(entry.getKey(), entry.getValue());
|
|
250
|
-
}
|
|
251
|
-
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(name, eventData);
|
|
251
|
+
/**
|
|
252
|
+
* Emits an event along with data to be handled by the Javascript
|
|
253
|
+
*
|
|
254
|
+
* @param name event name
|
|
255
|
+
* @param data data sent along with event
|
|
256
|
+
*/
|
|
257
|
+
private void emitEvent(final String name, final Map<String, String> data) {
|
|
258
|
+
WritableMap eventData = Arguments.createMap();
|
|
259
|
+
for (final Map.Entry<String, String> entry : data.entrySet()) {
|
|
260
|
+
eventData.putString(entry.getKey(), entry.getValue());
|
|
252
261
|
}
|
|
262
|
+
reactContext
|
|
263
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
264
|
+
.emit(name, eventData);
|
|
265
|
+
}
|
|
253
266
|
}
|
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
you may not use this file except in compliance with the License.
|
|
5
|
-
of the License at
|
|
6
|
-
Unless required by applicable law
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the
|
|
4
|
+
"License"); you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
|
|
7
|
+
or agreed to in writing, software distributed under the License is distributed
|
|
8
|
+
on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either
|
|
9
|
+
express or implied. See the License for the specific language governing
|
|
10
|
+
permissions and limitations under the License.
|
|
10
11
|
*/
|
|
11
12
|
package com.adobe.marketing.mobile.reactnative.messaging;
|
|
12
13
|
|
|
13
|
-
import java.util.Arrays;
|
|
14
|
-
import java.util.Collections;
|
|
15
|
-
import java.util.List;
|
|
16
|
-
|
|
17
14
|
import com.facebook.react.ReactPackage;
|
|
15
|
+
import com.facebook.react.bridge.JavaScriptModule;
|
|
18
16
|
import com.facebook.react.bridge.NativeModule;
|
|
19
17
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
20
18
|
import com.facebook.react.uimanager.ViewManager;
|
|
21
|
-
import
|
|
19
|
+
import java.util.Arrays;
|
|
20
|
+
import java.util.Collections;
|
|
21
|
+
import java.util.List;
|
|
22
22
|
public class RCTAEPMessagingPackage implements ReactPackage {
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
@Override
|
|
25
|
+
public List<NativeModule>
|
|
26
|
+
createNativeModules(ReactApplicationContext reactContext) {
|
|
27
|
+
return Arrays.<NativeModule>asList(new RCTAEPMessagingModule(reactContext));
|
|
28
|
+
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
// Deprecated from RN 0.47
|
|
31
|
+
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
32
|
+
return Collections.emptyList();
|
|
33
|
+
}
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
@Override
|
|
36
|
+
public List<ViewManager>
|
|
37
|
+
createViewManagers(ReactApplicationContext reactContext) {
|
|
38
|
+
return Collections.emptyList();
|
|
39
|
+
}
|
|
38
40
|
}
|