-
Notifications
You must be signed in to change notification settings - Fork 40
[SDK-196] Fix retryInterval not being able to be updated #786
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
base: jwt/master
Are you sure you want to change the base?
Changes from 7 commits
de5ed49
e9cb761
c48da84
ada0a72
177308b
45be7ed
0fca9f2
1a6d487
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.IterableActionContext; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.iterable.iterableapi.IterableApi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.iterable.iterableapi.IterableAuthHandler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.iterable.iterableapi.IterableAuthManager; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.iterable.iterableapi.IterableConfig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.iterable.iterableapi.IterableCustomActionHandler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.iterable.iterableapi.IterableAttributionInfo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -88,7 +89,36 @@ public void initializeWithApiKey(String apiKey, ReadableMap configReadableMap, S | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| configBuilder.setAuthHandler(this); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IterableApi.initialize(reactContext, apiKey, configBuilder.build()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IterableConfig config = configBuilder.build(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IterableApi.initialize(reactContext, apiKey, config); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Update retry policy on existing authManager if it was already created | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // This fixes the issue where retryInterval is not respected after | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // re-initialization | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // TODO [SDK-197]: Fix the root cause of this issue, instead of this hack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Use reflection to access package-private fields and methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| java.lang.reflect.Field configRetryPolicyField = config.getClass().getDeclaredField("retryPolicy"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| configRetryPolicyField.setAccessible(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Object retryPolicy = configRetryPolicyField.get(config); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (retryPolicy != null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| java.lang.reflect.Method getAuthManagerMethod = IterableApi.getInstance().getClass().getDeclaredMethod("getAuthManager"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getAuthManagerMethod.setAccessible(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IterableAuthManager authManager = (IterableAuthManager) getAuthManagerMethod.invoke(IterableApi.getInstance()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (authManager != null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Update the retry policy field on the authManager | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| java.lang.reflect.Field authRetryPolicyField = authManager.getClass().getDeclaredField("authRetryPolicy"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| authRetryPolicyField.setAccessible(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| authRetryPolicyField.set(authManager, retryPolicy); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IterableLogger.d(TAG, "Updated retry policy on existing authManager"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (Exception e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IterableLogger.e(TAG, "Failed to update retry policy: " + e.getMessage()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
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. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+95
to
+121
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Update retry policy on existing authManager if it was already created | |
| // This fixes the issue where retryInterval is not respected after | |
| // re-initialization | |
| // TODO [SDK-197]: Fix the root cause of this issue, instead of this hack | |
| try { | |
| // Use reflection to access package-private fields and methods | |
| java.lang.reflect.Field configRetryPolicyField = config.getClass().getDeclaredField("retryPolicy"); | |
| configRetryPolicyField.setAccessible(true); | |
| Object retryPolicy = configRetryPolicyField.get(config); | |
| if (retryPolicy != null) { | |
| java.lang.reflect.Method getAuthManagerMethod = IterableApi.getInstance().getClass().getDeclaredMethod("getAuthManager"); | |
| getAuthManagerMethod.setAccessible(true); | |
| IterableAuthManager authManager = (IterableAuthManager) getAuthManagerMethod.invoke(IterableApi.getInstance()); | |
| if (authManager != null) { | |
| // Update the retry policy field on the authManager | |
| java.lang.reflect.Field authRetryPolicyField = authManager.getClass().getDeclaredField("authRetryPolicy"); | |
| authRetryPolicyField.setAccessible(true); | |
| authRetryPolicyField.set(authManager, retryPolicy); | |
| IterableLogger.d(TAG, "Updated retry policy on existing authManager"); | |
| } | |
| } | |
| } catch (Exception e) { | |
| IterableLogger.e(TAG, "Failed to update retry policy: " + e.getMessage()); | |
| } | |
| // NOTE: Unable to update retry policy on existing authManager after initialization | |
| // until SDK-197 is resolved. Reflection-based hack removed for safety and maintainability. | |
| // If retryInterval is not respected after re-initialization, this is a known limitation. |
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
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.
Copilot
AI
Nov 21, 2025
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.
The code in this method (lines 162-183) is an exact duplicate of the reflection logic in initializeWithApiKey (lines 99-120). This violates the DRY (Don't Repeat Yourself) principle and makes maintenance harder.
Consider extracting this logic into a private helper method that can be called from both initialization methods:
private void updateAuthManagerRetryPolicy(IterableConfig config) {
// Move the try-catch block here
}| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -89,6 +89,8 @@ const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; | |||||
|
|
||||||
| const getIsEmail = (id: string) => EMAIL_REGEX.test(id); | ||||||
|
|
||||||
| let lastTimeStamp = 0; | ||||||
|
|
||||||
| export const IterableAppProvider: FunctionComponent< | ||||||
| React.PropsWithChildren<unknown> | ||||||
| > = ({ children }) => { | ||||||
|
|
@@ -141,17 +143,15 @@ export const IterableAppProvider: FunctionComponent< | |||||
|
|
||||||
| const initialize = useCallback( | ||||||
| (navigation: Navigation) => { | ||||||
| if (getUserId()) { | ||||||
| login(); | ||||||
| } | ||||||
| logout(); | ||||||
|
|
||||||
| const config = new IterableConfig(); | ||||||
|
|
||||||
| config.inAppDisplayInterval = 1.0; // Min gap between in-apps. No need to set this in production. | ||||||
|
|
||||||
| config.retryPolicy = { | ||||||
| maxRetry: 5, | ||||||
| retryInterval: 10, | ||||||
| retryInterval:5, | ||||||
|
||||||
| retryInterval:5, | |
| retryInterval: 5, |
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.
The changelog entry states that
retryIntervalis "not being updated on re-initialization," but based on the PR description, the actual fix is about converting seconds to milliseconds. However, this conversion is missing from the code changes in Serialization.java. The changelog should more accurately describe what was actually fixed (the workaround to update retry policy on existing authManager).