@adobe/react-native-aepmessaging 6.0.4 → 6.0.5
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.
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
package com.adobe.marketing.mobile.reactnative.messaging;
|
|
13
13
|
|
|
14
|
+
import static com.adobe.marketing.mobile.reactnative.messaging.RCTAEPMessagingUtil.convertMessageToMap;
|
|
15
|
+
|
|
14
16
|
import android.app.Activity;
|
|
15
17
|
|
|
16
18
|
import androidx.annotation.NonNull;
|
|
@@ -84,7 +86,11 @@ public final class RCTAEPMessagingModule
|
|
|
84
86
|
|
|
85
87
|
@ReactMethod
|
|
86
88
|
public void getLatestMessage(final Promise promise) {
|
|
87
|
-
|
|
89
|
+
if (this.latestMessage != null) {
|
|
90
|
+
promise.resolve(RCTAEPMessagingUtil.convertToReadableMap(convertMessageToMap(this.latestMessage)));
|
|
91
|
+
} else {
|
|
92
|
+
promise.resolve(null);
|
|
93
|
+
}
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
@ReactMethod
|
|
@@ -174,7 +180,7 @@ public final class RCTAEPMessagingModule
|
|
|
174
180
|
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
175
181
|
if (message != null) {
|
|
176
182
|
Map<String, String> data =
|
|
177
|
-
|
|
183
|
+
convertMessageToMap(message);
|
|
178
184
|
emitEvent("onShow", data);
|
|
179
185
|
}
|
|
180
186
|
}
|
|
@@ -185,7 +191,7 @@ public final class RCTAEPMessagingModule
|
|
|
185
191
|
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
186
192
|
if (message != null) {
|
|
187
193
|
Map<String, String> data =
|
|
188
|
-
|
|
194
|
+
convertMessageToMap(message);
|
|
189
195
|
emitEvent("onDismiss", data);
|
|
190
196
|
}
|
|
191
197
|
}
|
|
@@ -196,7 +202,7 @@ public final class RCTAEPMessagingModule
|
|
|
196
202
|
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
197
203
|
if (message != null) {
|
|
198
204
|
Map<String, String> data =
|
|
199
|
-
|
|
205
|
+
convertMessageToMap(message);
|
|
200
206
|
emitEvent("onHide", data);
|
|
201
207
|
}
|
|
202
208
|
}
|
|
@@ -207,7 +213,7 @@ public final class RCTAEPMessagingModule
|
|
|
207
213
|
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
208
214
|
if (message != null) {
|
|
209
215
|
Map<String, String> data =
|
|
210
|
-
|
|
216
|
+
convertMessageToMap(message);
|
|
211
217
|
emitEvent("shouldShowMessage", data);
|
|
212
218
|
// Latch stops the thread until the shouldShowMessage value is received
|
|
213
219
|
// from the JS side on thread dedicated to run JS code. The function
|
|
@@ -234,7 +240,7 @@ public final class RCTAEPMessagingModule
|
|
|
234
240
|
Message message = MessagingUtils.getMessageForPresentable((Presentable<InAppMessage>) presentable);
|
|
235
241
|
if (message != null) {
|
|
236
242
|
Map<String, String> data =
|
|
237
|
-
|
|
243
|
+
convertMessageToMap(message);
|
|
238
244
|
emitEvent("onContentLoaded", data);
|
|
239
245
|
}
|
|
240
246
|
}
|
|
@@ -263,4 +269,4 @@ public final class RCTAEPMessagingModule
|
|
|
263
269
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
264
270
|
.emit(name, eventData);
|
|
265
271
|
}
|
|
266
|
-
}
|
|
272
|
+
}
|
|
@@ -10,205 +10,210 @@
|
|
|
10
10
|
language governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
package com.adobe.marketing.mobile.reactnative.messaging;
|
|
14
|
-
|
|
15
|
-
import
|
|
16
|
-
import com.adobe.marketing.mobile.
|
|
17
|
-
import com.adobe.marketing.mobile.
|
|
18
|
-
import com.adobe.marketing.mobile.messaging.
|
|
19
|
-
import com.
|
|
20
|
-
import com.
|
|
21
|
-
import com.facebook.react.bridge.
|
|
22
|
-
import com.facebook.react.bridge.
|
|
23
|
-
import com.facebook.react.bridge.
|
|
24
|
-
import com.facebook.react.bridge.
|
|
25
|
-
import com.facebook.react.bridge.
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import java.util.
|
|
29
|
-
import java.util.
|
|
30
|
-
import java.util.
|
|
31
|
-
import java.util.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
13
|
+
package com.adobe.marketing.mobile.reactnative.messaging;
|
|
14
|
+
|
|
15
|
+
import com.adobe.marketing.mobile.Message;
|
|
16
|
+
import com.adobe.marketing.mobile.MessagingEdgeEventType;
|
|
17
|
+
import com.adobe.marketing.mobile.messaging.Proposition;
|
|
18
|
+
import com.adobe.marketing.mobile.messaging.Surface;
|
|
19
|
+
import com.facebook.react.bridge.Arguments;
|
|
20
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
21
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
22
|
+
import com.facebook.react.bridge.WritableArray;
|
|
23
|
+
import com.facebook.react.bridge.WritableMap;
|
|
24
|
+
import com.facebook.react.bridge.WritableNativeArray;
|
|
25
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
26
|
+
import java.util.ArrayList;
|
|
27
|
+
import java.util.Collection;
|
|
28
|
+
import java.util.HashMap;
|
|
29
|
+
import java.util.Iterator;
|
|
30
|
+
import java.util.List;
|
|
31
|
+
import java.util.Map;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Utility class for converting data models to {@link
|
|
35
|
+
* com.facebook.react.bridge.WritableMap}
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
class RCTAEPMessagingUtil {
|
|
39
|
+
|
|
40
|
+
private static final String TAG = "RCTAEPMessaging";
|
|
41
|
+
|
|
42
|
+
private RCTAEPMessagingUtil() {}
|
|
43
|
+
|
|
44
|
+
// From React Native
|
|
45
|
+
static MessagingEdgeEventType getEventType(final int eventType) {
|
|
46
|
+
switch (eventType) {
|
|
47
|
+
case 0:
|
|
48
|
+
return MessagingEdgeEventType.DISMISS;
|
|
49
|
+
case 1:
|
|
50
|
+
return MessagingEdgeEventType.INTERACT;
|
|
51
|
+
case 2:
|
|
52
|
+
return MessagingEdgeEventType.TRIGGER;
|
|
53
|
+
case 3:
|
|
54
|
+
return MessagingEdgeEventType.DISPLAY;
|
|
55
|
+
case 4:
|
|
56
|
+
return MessagingEdgeEventType.PUSH_APPLICATION_OPENED;
|
|
57
|
+
case 5:
|
|
58
|
+
return MessagingEdgeEventType.PUSH_CUSTOM_ACTION;
|
|
59
|
+
default:
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static List<Surface> convertSurfaces(final ReadableArray rawSurfaces) {
|
|
65
|
+
List<Surface> surfaces = new ArrayList<>();
|
|
66
|
+
|
|
67
|
+
for (int i = 0; i < rawSurfaces.size(); i++) {
|
|
68
|
+
surfaces.add(new Surface(rawSurfaces.getString(i)));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return surfaces;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// To React Native
|
|
75
|
+
static WritableMap toWritableMap(Map<String, Object> map) {
|
|
76
|
+
if (map == null) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
WritableMap writableMap = Arguments.createMap();
|
|
81
|
+
Iterator iterator = map.entrySet().iterator();
|
|
82
|
+
|
|
83
|
+
while (iterator.hasNext()) {
|
|
84
|
+
Map.Entry pair = (Map.Entry)iterator.next();
|
|
85
|
+
Object value = pair.getValue();
|
|
86
|
+
|
|
87
|
+
if (value == null) {
|
|
88
|
+
writableMap.putNull((String)pair.getKey());
|
|
89
|
+
} else if (value instanceof Boolean) {
|
|
90
|
+
writableMap.putBoolean((String)pair.getKey(), (Boolean)value);
|
|
91
|
+
} else if (value instanceof Double) {
|
|
92
|
+
writableMap.putDouble((String)pair.getKey(), (Double)value);
|
|
93
|
+
} else if (value instanceof Integer) {
|
|
94
|
+
writableMap.putInt((String)pair.getKey(), (Integer)value);
|
|
95
|
+
} else if (value instanceof String) {
|
|
96
|
+
writableMap.putString((String)pair.getKey(), (String)value);
|
|
97
|
+
} else if (value instanceof Map) {
|
|
98
|
+
writableMap.putMap((String)pair.getKey(),
|
|
99
|
+
toWritableMap((Map<String, Object>)value));
|
|
100
|
+
} else if (value instanceof List) {
|
|
101
|
+
writableMap.putArray((String)pair.getKey(),
|
|
102
|
+
toWritableArray((List)value));
|
|
103
|
+
} else if (value.getClass() != null && value.getClass().isArray()) {
|
|
104
|
+
writableMap.putArray((String)pair.getKey(),
|
|
105
|
+
toWritableArray((Object[])value));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return writableMap;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static WritableArray toWritableArray(Object[] array) {
|
|
113
|
+
if (array == null) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
WritableArray writableArr = Arguments.createArray();
|
|
117
|
+
|
|
118
|
+
for (int i = 0; i < array.length; i++) {
|
|
119
|
+
Object value = array[i];
|
|
120
|
+
|
|
121
|
+
if (value == null) {
|
|
122
|
+
writableArr.pushNull();
|
|
123
|
+
} else if (value instanceof Boolean) {
|
|
124
|
+
writableArr.pushBoolean((Boolean)value);
|
|
125
|
+
} else if (value instanceof Double) {
|
|
126
|
+
writableArr.pushDouble((Double)value);
|
|
127
|
+
} else if (value instanceof Integer) {
|
|
128
|
+
writableArr.pushInt((Integer)value);
|
|
129
|
+
} else if (value instanceof String) {
|
|
130
|
+
writableArr.pushString((String)value);
|
|
131
|
+
} else if (value instanceof Map) {
|
|
132
|
+
writableArr.pushMap(toWritableMap((Map<String, Object>)value));
|
|
133
|
+
} else if (value instanceof List) {
|
|
134
|
+
writableArr.pushArray(toWritableArray((List)value));
|
|
135
|
+
} else if (value.getClass().isArray()) {
|
|
136
|
+
writableArr.pushArray(toWritableArray((Object[])value));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return writableArr;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static WritableArray toWritableArray(List array) {
|
|
144
|
+
if (array == null) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
WritableArray writableArr = Arguments.createArray();
|
|
148
|
+
|
|
149
|
+
for (Object value : array) {
|
|
150
|
+
if (value == null) {
|
|
151
|
+
writableArr.pushNull();
|
|
152
|
+
} else if (value instanceof Boolean) {
|
|
153
|
+
writableArr.pushBoolean((Boolean)value);
|
|
154
|
+
} else if (value instanceof Double) {
|
|
155
|
+
writableArr.pushDouble((Double)value);
|
|
156
|
+
} else if (value instanceof Integer) {
|
|
157
|
+
writableArr.pushInt((Integer)value);
|
|
158
|
+
} else if (value instanceof String) {
|
|
159
|
+
writableArr.pushString((String)value);
|
|
160
|
+
} else if (value instanceof Map) {
|
|
161
|
+
writableArr.pushMap(toWritableMap((Map<String, Object>)value));
|
|
162
|
+
} else if (value instanceof List) {
|
|
163
|
+
writableArr.pushArray(toWritableArray((List)value));
|
|
164
|
+
} else if (value.getClass().isArray()) {
|
|
165
|
+
writableArr.pushArray(toWritableArray((Object[])value));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return writableArr;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
static Map<String, String> convertMessageToMap(final Message message) {
|
|
173
|
+
Map<String, String> data = new HashMap<>();
|
|
174
|
+
data.put("id", message.getId());
|
|
175
|
+
data.put("autoTrack", String.valueOf(message.getAutoTrack()));
|
|
176
|
+
return data;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
static ReadableArray convertMessagesToJS(final Collection<Message> messages) {
|
|
180
|
+
WritableArray result = new WritableNativeArray();
|
|
181
|
+
|
|
182
|
+
for (Message message : messages) {
|
|
183
|
+
result.pushMap(convertToReadableMap(convertMessageToMap(message)));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
static WritableMap convertSurfacePropositions(
|
|
190
|
+
final Map<Surface, List<Proposition>> propositionMap,
|
|
191
|
+
String packageName) {
|
|
192
|
+
WritableMap data = new WritableNativeMap();
|
|
193
|
+
|
|
194
|
+
for (Map.Entry<Surface, List<Proposition>> entry :
|
|
195
|
+
propositionMap.entrySet()) {
|
|
196
|
+
String key = entry.getKey().getUri().replace(
|
|
197
|
+
"mobileapp://" + packageName + "/", "");
|
|
198
|
+
WritableArray propositions = new WritableNativeArray();
|
|
199
|
+
|
|
200
|
+
for (Iterator<Proposition> iterator = entry.getValue().iterator();
|
|
201
|
+
iterator.hasNext();) {
|
|
202
|
+
propositions.pushMap(toWritableMap(iterator.next().toEventData()));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
data.putArray(key, propositions);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return data;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
static ReadableMap convertToReadableMap(Map<String, String> map) {
|
|
212
|
+
WritableMap writableMap = Arguments.createMap();
|
|
213
|
+
|
|
214
|
+
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
215
|
+
writableMap.putString(entry.getKey(), entry.getValue());
|
|
216
|
+
}
|
|
217
|
+
return writableMap;
|
|
218
|
+
}
|
|
219
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/react-native-aepmessaging",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.5",
|
|
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",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"installConfig": {
|
|
40
40
|
"hoistingLimits": "dependencies"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "d907afaf1a8d7521a95ab744bf0e7ea6890e79db"
|
|
43
43
|
}
|