-
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 3 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,34 @@ 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 | ||
| 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
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. |
||
| } | ||
|
|
||
| IterableApi.getInstance().setDeviceAttribute("reactNativeSDKVersion", version); | ||
|
|
||
| IterableApi.getInstance().getInAppManager().addListener(this); | ||
|
|
@@ -122,7 +150,34 @@ public void initialize2WithApiKey(String apiKey, ReadableMap configReadableMap, | |
| // override in the Android SDK. Check with @Ayyanchira and @evantk91 to | ||
| // see what the best approach is. | ||
|
|
||
| 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 | ||
| 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
+162
to
+183
|
||
|
|
||
| IterableApi.getInstance().setDeviceAttribute("reactNativeSDKVersion", version); | ||
|
|
||
| IterableApi.getInstance().getInAppManager().addListener(this); | ||
|
|
||
| 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, |
Uh oh!
There was an error while loading. Please reload this page.