-
Notifications
You must be signed in to change notification settings - Fork 42
[MOB-10947][SDK-88] Configure JWT for Android #727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 18 commits
8975ac1
ab8efaa
1972fbb
2cd8253
fd74351
ef86b15
372df66
a7804e5
21ca59d
18cba09
050ad22
60bc88e
5fbb9c9
5e4e579
3737d57
7b8fdb1
67a806d
b31ffd7
ed20041
0191b7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| import com.iterable.iterableapi.IterableInboxSession; | ||
| import com.iterable.iterableapi.IterableLogger; | ||
| import com.iterable.iterableapi.RNIterableInternal; | ||
| import com.iterable.iterableapi.RetryPolicy; | ||
|
|
||
| import org.json.JSONArray; | ||
| import org.json.JSONException; | ||
|
|
@@ -94,7 +95,7 @@ static CommerceItem commerceItemFromMap(JSONObject itemMap) throws JSONException | |
| categories[i] = categoriesArray.getString(i); | ||
| } | ||
| } | ||
|
|
||
| return new CommerceItem(itemMap.getString("id"), | ||
| itemMap.getString("name"), | ||
| itemMap.getDouble("price"), | ||
|
|
@@ -216,9 +217,17 @@ static IterableConfig.Builder getConfigFromReadableMap(ReadableMap iterableConte | |
|
|
||
| configBuilder.setDataRegion(iterableDataRegion); | ||
| } | ||
|
|
||
| if (iterableContextJSON.has("encryptionEnforced")) { | ||
| configBuilder.setEncryptionEnforced(iterableContextJSON.optBoolean("encryptionEnforced")); | ||
|
|
||
| if (iterableContextJSON.has("retryPolicy")) { | ||
| JSONObject retryPolicyJson = iterableContextJSON.getJSONObject("retryPolicy"); | ||
| int maxRetry = retryPolicyJson.getInt("maxRetry"); | ||
| long retryInterval = retryPolicyJson.getLong("retryInterval"); | ||
| String retryBackoff = retryPolicyJson.getString("retryBackoff"); | ||
| RetryPolicy.Type retryPolicyType = RetryPolicy.Type.LINEAR; | ||
| if (retryBackoff.equals("EXPONENTIAL")) { | ||
| retryPolicyType = RetryPolicy.Type.EXPONENTIAL; | ||
| } | ||
| configBuilder.setAuthRetryPolicy(new RetryPolicy(maxRetry, retryInterval, retryPolicyType)); | ||
|
Comment on lines
+221
to
+230
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to see RetryPolicy coming all the way from TS and getting applied at core level!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was all you from the previous work we did 🥇 |
||
| } | ||
|
|
||
| return configBuilder; | ||
|
|
@@ -257,7 +266,13 @@ static JSONObject actionContextToJson(IterableActionContext iterableActionContex | |
| } | ||
|
|
||
| static IterableInboxSession.Impression inboxImpressionFromMap(JSONObject impressionMap) throws JSONException { | ||
| return new IterableInboxSession.Impression(impressionMap.getString("messageId"), | ||
| // Add null check for messageId to prevent NullPointerException | ||
| String messageId = impressionMap.optString("messageId", null); | ||
| if (messageId == null || messageId.isEmpty()) { | ||
| throw new JSONException("messageId is null or empty"); | ||
| } | ||
|
|
||
| return new IterableInboxSession.Impression(messageId, | ||
| impressionMap.getBoolean("silentInbox"), | ||
| impressionMap.optInt("displayCount", 0), | ||
| (float) impressionMap.optDouble("duration", 0) | ||
|
|
@@ -271,8 +286,13 @@ static List<IterableInboxSession.Impression> impressionsFromReadableArray(Readab | |
| JSONArray impressionJsonArray = convertArrayToJson(array); | ||
|
|
||
| for (int i = 0; i < impressionJsonArray.length(); i++) { | ||
| JSONObject impressionObj = impressionJsonArray.getJSONObject(i); | ||
| list.add(inboxImpressionFromMap(impressionObj)); | ||
| try { | ||
| JSONObject impressionObj = impressionJsonArray.getJSONObject(i); | ||
| list.add(inboxImpressionFromMap(impressionObj)); | ||
| } catch (JSONException e) { | ||
| // Skip invalid entries instead of failing completely | ||
| IterableLogger.w(TAG, "Skipping invalid impression at index " + i + ": " + e.getLocalizedMessage()); | ||
| } | ||
| } | ||
| } catch (JSONException e) { | ||
| IterableLogger.e(TAG, "Failed converting to JSONObject"); | ||
|
|
@@ -286,7 +306,7 @@ static List<IterableInboxSession.Impression> impressionsFromReadableArray(Readab | |
| // --------------------------------------------------------------------------------------- | ||
| // region React Native JSON conversion methods | ||
| // obtained from https://gist.github.com/viperwarp/2beb6bbefcc268dee7ad | ||
|
|
||
| static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException { | ||
| WritableMap map = new WritableNativeMap(); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,16 +95,30 @@ export const IterableInboxMessageList = ({ | |
| function getRowInfosFromViewTokens( | ||
| viewTokens: Array<ViewToken> | ||
| ): Array<IterableInboxImpressionRowInfo> { | ||
| return viewTokens.map(function (viewToken) { | ||
| const inAppMessage = IterableInAppMessage.fromViewToken(viewToken); | ||
| return viewTokens | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's given by the At times, |
||
| .filter((viewToken) => { | ||
| // Filter out viewTokens that don't have valid items or inAppMessage | ||
| return viewToken?.item?.inAppMessage?.messageId; | ||
| }) | ||
| .map(function (viewToken) { | ||
| try { | ||
| const inAppMessage = IterableInAppMessage.fromViewToken(viewToken); | ||
|
|
||
| const impression = { | ||
| messageId: inAppMessage.messageId, | ||
| silentInbox: inAppMessage.isSilentInbox(), | ||
| } as IterableInboxImpressionRowInfo; | ||
| const impression = { | ||
| messageId: inAppMessage?.messageId, | ||
| silentInbox: inAppMessage?.isSilentInbox(), | ||
| } as IterableInboxImpressionRowInfo; | ||
|
|
||
| return impression; | ||
| }); | ||
| return impression; | ||
| } catch (error) { | ||
| // Log the error and return null to be filtered out | ||
| console.warn('Failed to create impression from ViewToken:', error); | ||
| return null; | ||
| } | ||
| }) | ||
| .filter( | ||
| (impression) => impression !== null | ||
| ) as Array<IterableInboxImpressionRowInfo>; | ||
| } | ||
|
|
||
| const inboxSessionViewabilityConfig: ViewabilityConfig = { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we delete this method altogether as its replaced by onAuthFailure now?