Skip to content

Commit 93bf1d4

Browse files
authored
Merge pull request #284 from Iterable/jay/MOB-3923-allowed-protocols
[MOB-3923] RN SDK allowed protocols
2 parents 6cfb751 + 31dff16 commit 93bf1d4

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

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
}

ios/RNIterableAPI/Serialization.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ extension IterableConfig {
4343
return config
4444
}
4545

46+
if let allowedProtocols = dict["allowedProtocols"] as? [String] {
47+
config.allowedProtocols = allowedProtocols
48+
}
49+
4650
if let pushIntegrationName = dict["pushIntegrationName"] as? String {
4751
config.pushIntegrationName = pushIntegrationName
4852
}

ts/Iterable.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ class IterableConfig {
9797
*/
9898
expiringAuthTokenRefreshPeriod: number = 60.0
9999

100+
/**
101+
* We allow navigation only to urls with `https` protocol (for deep links within your app or external links).
102+
* If you want to allow other protocols, such as, `http`, `tel` etc., please add them to the list below
103+
*/
104+
allowedProtocols: Array<string> = []
105+
100106
toDict(): any {
101107
return {
102108
"pushIntegrationName": this.pushIntegrationName,
@@ -107,7 +113,8 @@ class IterableConfig {
107113
"inAppHandlerPresent": this.inAppHandler != undefined,
108114
"authHandlerPresent": this.authHandler != undefined,
109115
"logLevel": this.logLevel,
110-
"expiringAuthTokenRefreshPeriod": this.expiringAuthTokenRefreshPeriod
116+
"expiringAuthTokenRefreshPeriod": this.expiringAuthTokenRefreshPeriod,
117+
"allowedProtocols": this.allowedProtocols
111118
}
112119
}
113120
}

0 commit comments

Comments
 (0)