Skip to content

Commit 31dff16

Browse files
committed
move protocols serialization to right spot
1 parent a642b03 commit 31dff16

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

android/src/main/java/com/iterable/reactnative/RNIterableAPIModule.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,6 @@ public void initializeWithApiKey(String apiKey, ReadableMap configReadableMap, S
7676
IterableLogger.d(TAG, "initializeWithApiKey: " + apiKey);
7777
IterableConfig.Builder configBuilder = Serialization.getConfigFromReadableMap(configReadableMap);
7878

79-
if (configReadableMap.hasKey("allowedProtocols")) {
80-
String[] allowedProtocols = readableArrayToStringArray(configReadableMap.getArray("allowedProtocols"));
81-
82-
if (allowedProtocols != null) {
83-
configBuilder.setAllowedProtocols(allowedProtocols);
84-
}
85-
}
86-
8779
if (configReadableMap.hasKey("urlHandlerPresent") && configReadableMap.getBoolean("urlHandlerPresent") == true) {
8880
configBuilder.setUrlHandler(this);
8981
}
@@ -433,20 +425,6 @@ private static Integer[] readableArrayToIntegerArray(ReadableArray array) {
433425
return integers;
434426
}
435427

436-
private static String[] readableArrayToStringArray(ReadableArray array) {
437-
if (array == null) {
438-
return null;
439-
}
440-
441-
String[] strings = new String[array.size()];
442-
443-
for (int i = 0; i < array.size(); i++) {
444-
strings[i] = array.getString(i);
445-
}
446-
447-
return strings;
448-
}
449-
450428
@Nullable
451429
private static JSONObject optSerializedDataFields(ReadableMap dataFields) {
452430
JSONObject dataFieldsJson = null;

android/src/main/java/com/iterable/reactnative/Serialization.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,21 @@ static IterableConfig.Builder getConfigFromReadableMap(ReadableMap iterableConte
139139
JSONObject iterableContextJSON = convertMapToJson(iterableContextMap);
140140

141141
IterableConfig.Builder configBuilder = new IterableConfig.Builder();
142+
143+
if (iterableContextJSON.has("allowedProtocols")) {
144+
WritableArray allowedProtocolsArray = convertJsonToArray(iterableContextJSON.getJSONArray("allowedProtocols"));
145+
146+
String[] allowedProtocols = new String[allowedProtocolsArray.size()];
147+
148+
for (int i = 0; i < allowedProtocolsArray.size(); i++) {
149+
allowedProtocols[i] = allowedProtocolsArray.getString(i);
150+
}
151+
152+
if (allowedProtocols != null) {
153+
configBuilder.setAllowedProtocols(allowedProtocols);
154+
}
155+
}
156+
142157
if (iterableContextJSON.has("pushIntegrationName")) {
143158
configBuilder.setPushIntegrationName(iterableContextJSON.optString("pushIntegrationName"));
144159
}

0 commit comments

Comments
 (0)