@adobe/react-native-aepmessaging 6.0.2 → 6.0.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.
|
@@ -18,10 +18,13 @@ import com.adobe.marketing.mobile.MessagingEdgeEventType;
|
|
|
18
18
|
import com.adobe.marketing.mobile.messaging.Proposition;
|
|
19
19
|
import com.adobe.marketing.mobile.messaging.PropositionItem;
|
|
20
20
|
import com.adobe.marketing.mobile.messaging.Surface;
|
|
21
|
+
import com.facebook.react.bridge.Arguments;
|
|
21
22
|
import com.facebook.react.bridge.ReadableArray;
|
|
22
23
|
import com.facebook.react.bridge.ReadableMap;
|
|
23
24
|
import com.facebook.react.bridge.WritableArray;
|
|
25
|
+
import com.facebook.react.bridge.WritableMap;
|
|
24
26
|
import com.facebook.react.bridge.WritableNativeArray;
|
|
27
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
25
28
|
import java.util.ArrayList;
|
|
26
29
|
import java.util.Collection;
|
|
27
30
|
import java.util.HashMap;
|
|
@@ -72,6 +75,102 @@ class RCTAEPMessagingUtil {
|
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
// To React Native
|
|
78
|
+
static WritableMap toWritableMap(Map<String, Object> map) {
|
|
79
|
+
if (map == null) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
WritableMap writableMap = Arguments.createMap();
|
|
84
|
+
Iterator iterator = map.entrySet().iterator();
|
|
85
|
+
|
|
86
|
+
while (iterator.hasNext()) {
|
|
87
|
+
Map.Entry pair = (Map.Entry)iterator.next();
|
|
88
|
+
Object value = pair.getValue();
|
|
89
|
+
|
|
90
|
+
if (value == null) {
|
|
91
|
+
writableMap.putNull((String)pair.getKey());
|
|
92
|
+
} else if (value instanceof Boolean) {
|
|
93
|
+
writableMap.putBoolean((String)pair.getKey(), (Boolean)value);
|
|
94
|
+
} else if (value instanceof Double) {
|
|
95
|
+
writableMap.putDouble((String)pair.getKey(), (Double)value);
|
|
96
|
+
} else if (value instanceof Integer) {
|
|
97
|
+
writableMap.putInt((String)pair.getKey(), (Integer)value);
|
|
98
|
+
} else if (value instanceof String) {
|
|
99
|
+
writableMap.putString((String)pair.getKey(), (String)value);
|
|
100
|
+
} else if (value instanceof Map) {
|
|
101
|
+
writableMap.putMap((String)pair.getKey(),
|
|
102
|
+
toWritableMap((Map<String, Object>)value));
|
|
103
|
+
} else if (value instanceof List) {
|
|
104
|
+
writableMap.putArray((String)pair.getKey(),
|
|
105
|
+
toWritableArray((List)value));
|
|
106
|
+
} else if (value.getClass() != null && value.getClass().isArray()) {
|
|
107
|
+
writableMap.putArray((String)pair.getKey(),
|
|
108
|
+
toWritableArray((Object[])value));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return writableMap;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static WritableArray toWritableArray(Object[] array) {
|
|
116
|
+
if (array == null) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
WritableArray writableArr = Arguments.createArray();
|
|
120
|
+
|
|
121
|
+
for (int i = 0; i < array.length; i++) {
|
|
122
|
+
Object value = array[i];
|
|
123
|
+
|
|
124
|
+
if (value == null) {
|
|
125
|
+
writableArr.pushNull();
|
|
126
|
+
} else if (value instanceof Boolean) {
|
|
127
|
+
writableArr.pushBoolean((Boolean)value);
|
|
128
|
+
} else if (value instanceof Double) {
|
|
129
|
+
writableArr.pushDouble((Double)value);
|
|
130
|
+
} else if (value instanceof Integer) {
|
|
131
|
+
writableArr.pushInt((Integer)value);
|
|
132
|
+
} else if (value instanceof String) {
|
|
133
|
+
writableArr.pushString((String)value);
|
|
134
|
+
} else if (value instanceof Map) {
|
|
135
|
+
writableArr.pushMap(toWritableMap((Map<String, Object>)value));
|
|
136
|
+
} else if (value instanceof List) {
|
|
137
|
+
writableArr.pushArray(toWritableArray((List)value));
|
|
138
|
+
} else if (value.getClass().isArray()) {
|
|
139
|
+
writableArr.pushArray(toWritableArray((Object[])value));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return writableArr;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static WritableArray toWritableArray(List array) {
|
|
147
|
+
if (array == null) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
WritableArray writableArr = Arguments.createArray();
|
|
151
|
+
|
|
152
|
+
for (Object value : array) {
|
|
153
|
+
if (value == null) {
|
|
154
|
+
writableArr.pushNull();
|
|
155
|
+
} else if (value instanceof Boolean) {
|
|
156
|
+
writableArr.pushBoolean((Boolean)value);
|
|
157
|
+
} else if (value instanceof Double) {
|
|
158
|
+
writableArr.pushDouble((Double)value);
|
|
159
|
+
} else if (value instanceof Integer) {
|
|
160
|
+
writableArr.pushInt((Integer)value);
|
|
161
|
+
} else if (value instanceof String) {
|
|
162
|
+
writableArr.pushString((String)value);
|
|
163
|
+
} else if (value instanceof Map) {
|
|
164
|
+
writableArr.pushMap(toWritableMap((Map<String, Object>)value));
|
|
165
|
+
} else if (value instanceof List) {
|
|
166
|
+
writableArr.pushArray(toWritableArray((List)value));
|
|
167
|
+
} else if (value.getClass().isArray()) {
|
|
168
|
+
writableArr.pushArray(toWritableArray((Object[])value));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return writableArr;
|
|
173
|
+
}
|
|
75
174
|
|
|
76
175
|
static Map convertMessageToMap(final Message message) {
|
|
77
176
|
Map data = new HashMap<>();
|
|
@@ -91,42 +190,23 @@ class RCTAEPMessagingUtil {
|
|
|
91
190
|
return result;
|
|
92
191
|
}
|
|
93
192
|
|
|
94
|
-
static
|
|
95
|
-
convertMessagingPropositionToJS(final Proposition proposition) {
|
|
96
|
-
Map data = new HashMap<>();
|
|
97
|
-
ArrayList<Map> propositionItems = new ArrayList();
|
|
98
|
-
ListIterator<PropositionItem> it =
|
|
99
|
-
proposition.getItems().listIterator();
|
|
100
|
-
|
|
101
|
-
while (it.hasNext()) {
|
|
102
|
-
Map item = new HashMap<>();
|
|
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());
|
|
110
|
-
propositionItems.add(item);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
data.put("scope", proposition.getScope());
|
|
114
|
-
data.put("uniqueId", proposition.getUniqueId());
|
|
115
|
-
data.put("items", propositionItems);
|
|
116
|
-
|
|
117
|
-
return data;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
static Map convertSurfacePropositions(
|
|
193
|
+
static WritableMap convertSurfacePropositions(
|
|
121
194
|
final Map<Surface, List<Proposition>> propositionMap,
|
|
122
195
|
String packageName) {
|
|
123
|
-
|
|
196
|
+
WritableMap data = new WritableNativeMap();
|
|
124
197
|
|
|
125
198
|
for (Map.Entry<Surface, List<Proposition>> entry :
|
|
126
199
|
propositionMap.entrySet()) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
200
|
+
String key = entry.getKey().getUri().replace(
|
|
201
|
+
"mobileapp://" + packageName + "/", "");
|
|
202
|
+
WritableArray propositions = new WritableNativeArray();
|
|
203
|
+
|
|
204
|
+
for (Iterator<Proposition> iterator = entry.getValue().iterator();
|
|
205
|
+
iterator.hasNext();) {
|
|
206
|
+
propositions.pushMap(toWritableMap(iterator.next().toEventData()));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
data.putArray(key, propositions);
|
|
130
210
|
}
|
|
131
211
|
|
|
132
212
|
return data;
|
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.3",
|
|
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": "669515b9ea55df50203ac191f8667330717bc608"
|
|
43
43
|
}
|