2424import com .iterable .iterableapi .IterableInboxSession ;
2525import com .iterable .iterableapi .IterableLogger ;
2626import com .iterable .iterableapi .RNIterableInternal ;
27+ import com .iterable .iterableapi .RetryPolicy ;
2728
2829import org .json .JSONArray ;
2930import org .json .JSONException ;
@@ -94,7 +95,7 @@ static CommerceItem commerceItemFromMap(JSONObject itemMap) throws JSONException
9495 categories [i ] = categoriesArray .getString (i );
9596 }
9697 }
97-
98+
9899 return new CommerceItem (itemMap .getString ("id" ),
99100 itemMap .getString ("name" ),
100101 itemMap .getDouble ("price" ),
@@ -216,9 +217,17 @@ static IterableConfig.Builder getConfigFromReadableMap(ReadableMap iterableConte
216217
217218 configBuilder .setDataRegion (iterableDataRegion );
218219 }
219-
220- if (iterableContextJSON .has ("encryptionEnforced" )) {
221- configBuilder .setEncryptionEnforced (iterableContextJSON .optBoolean ("encryptionEnforced" ));
220+
221+ if (iterableContextJSON .has ("retryPolicy" )) {
222+ JSONObject retryPolicyJson = iterableContextJSON .getJSONObject ("retryPolicy" );
223+ int maxRetry = retryPolicyJson .getInt ("maxRetry" );
224+ long retryInterval = retryPolicyJson .getLong ("retryInterval" );
225+ String retryBackoff = retryPolicyJson .getString ("retryBackoff" );
226+ RetryPolicy .Type retryPolicyType = RetryPolicy .Type .LINEAR ;
227+ if (retryBackoff .equals ("EXPONENTIAL" )) {
228+ retryPolicyType = RetryPolicy .Type .EXPONENTIAL ;
229+ }
230+ configBuilder .setAuthRetryPolicy (new RetryPolicy (maxRetry , retryInterval , retryPolicyType ));
222231 }
223232
224233 return configBuilder ;
@@ -257,7 +266,13 @@ static JSONObject actionContextToJson(IterableActionContext iterableActionContex
257266 }
258267
259268 static IterableInboxSession .Impression inboxImpressionFromMap (JSONObject impressionMap ) throws JSONException {
260- return new IterableInboxSession .Impression (impressionMap .getString ("messageId" ),
269+ // Add null check for messageId to prevent NullPointerException
270+ String messageId = impressionMap .optString ("messageId" , null );
271+ if (messageId == null || messageId .isEmpty ()) {
272+ throw new JSONException ("messageId is null or empty" );
273+ }
274+
275+ return new IterableInboxSession .Impression (messageId ,
261276 impressionMap .getBoolean ("silentInbox" ),
262277 impressionMap .optInt ("displayCount" , 0 ),
263278 (float ) impressionMap .optDouble ("duration" , 0 )
@@ -271,8 +286,13 @@ static List<IterableInboxSession.Impression> impressionsFromReadableArray(Readab
271286 JSONArray impressionJsonArray = convertArrayToJson (array );
272287
273288 for (int i = 0 ; i < impressionJsonArray .length (); i ++) {
274- JSONObject impressionObj = impressionJsonArray .getJSONObject (i );
275- list .add (inboxImpressionFromMap (impressionObj ));
289+ try {
290+ JSONObject impressionObj = impressionJsonArray .getJSONObject (i );
291+ list .add (inboxImpressionFromMap (impressionObj ));
292+ } catch (JSONException e ) {
293+ // Skip invalid entries instead of failing completely
294+ IterableLogger .w (TAG , "Skipping invalid impression at index " + i + ": " + e .getLocalizedMessage ());
295+ }
276296 }
277297 } catch (JSONException e ) {
278298 IterableLogger .e (TAG , "Failed converting to JSONObject" );
@@ -286,7 +306,7 @@ static List<IterableInboxSession.Impression> impressionsFromReadableArray(Readab
286306 // ---------------------------------------------------------------------------------------
287307 // region React Native JSON conversion methods
288308 // obtained from https://gist.github.com/viperwarp/2beb6bbefcc268dee7ad
289-
309+
290310 static WritableMap convertJsonToMap (JSONObject jsonObject ) throws JSONException {
291311 WritableMap map = new WritableNativeMap ();
292312
0 commit comments