Skip to content

Commit a642b03

Browse files
committed
serialize allowed protocols on andorid
1 parent 72e0819 commit a642b03

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ 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+
7987
if (configReadableMap.hasKey("urlHandlerPresent") && configReadableMap.getBoolean("urlHandlerPresent") == true) {
8088
configBuilder.setUrlHandler(this);
8189
}
@@ -425,6 +433,20 @@ private static Integer[] readableArrayToIntegerArray(ReadableArray array) {
425433
return integers;
426434
}
427435

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+
428450
@Nullable
429451
private static JSONObject optSerializedDataFields(ReadableMap dataFields) {
430452
JSONObject dataFieldsJson = null;

0 commit comments

Comments
 (0)