Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions android/src/main/java/com/iterable/reactnative/Serialization.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -217,6 +218,18 @@ static IterableConfig.Builder getConfigFromReadableMap(ReadableMap iterableConte
configBuilder.setDataRegion(iterableDataRegion);
}

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));
}

return configBuilder;
} catch (JSONException e) {
e.printStackTrace();
Expand Down
8 changes: 7 additions & 1 deletion example/src/hooks/useIterableApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {

import { Route } from '../constants/routes';
import type { RootStackParamList } from '../types/navigation';
import type { IterableAuthFailure } from '../../../src/core';
import { type IterableAuthFailure, IterableRetryBackoffType } from '../../../src/core';

type Navigation = StackNavigationProp<RootStackParamList>;

Expand Down Expand Up @@ -148,6 +148,12 @@ export const IterableAppProvider: FunctionComponent<

config.logLevel = IterableLogLevel.debug;

config.retryPolicy = {
maxRetry: 5,
retryInterval: 10,
retryBackoff: IterableRetryBackoffType.LINEAR
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insert ; [eslint:prettier/prettier]

Suggested change
}
};


config.inAppHandler = () => IterableInAppShowResponse.show;

config.authHandler = () => {
Expand Down
9 changes: 8 additions & 1 deletion src/core/classes/IterableConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
IterableLogLevel,
IterablePushPlatform,
} from '../enums';
import type { IterableRetryPolicy, IterableAuthFailure } from '../types';
import { IterableAction } from './IterableAction';
import type { IterableActionContext } from './IterableActionContext';
import type { IterableAuthResponse } from './IterableAuthResponse';
import type { IterableAuthFailure } from '../types/IterableAuthFailure';
/**
* An IterableConfig object sets various properties of the SDK.
*
Expand Down Expand Up @@ -302,6 +302,12 @@ export class IterableConfig {
*/
encryptionEnforced = false;

/**
* Configuration for JWT refresh retry behavior.
* If not specified, the SDK will use default retry behavior.
*/
retryPolicy?: IterableRetryPolicy;

/**
* Converts the IterableConfig instance to a dictionary object.
*
Expand Down Expand Up @@ -350,6 +356,7 @@ export class IterableConfig {
dataRegion: this.dataRegion,
pushPlatform: this.pushPlatform,
encryptionEnforced: this.encryptionEnforced,
retryPolicy: this.retryPolicy,
};
}
}
7 changes: 7 additions & 0 deletions src/core/enums/IterableRetryBackoffType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

* Enum representing the type of backoff pattern to apply between retry attempts.
*/
export enum IterableRetryBackoffType {
LINEAR = 'LINEAR',
EXPONENTIAL = 'EXPONENTIAL',
}
1 change: 1 addition & 0 deletions src/core/enums/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './IterableDataRegion';
export * from './IterableEventName';
export * from './IterableLogLevel';
export * from './IterablePushPlatform';
export * from './IterableRetryBackoffType';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insert [eslint:prettier/prettier]

17 changes: 17 additions & 0 deletions src/core/types/IterableRetryPolicy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { IterableRetryBackoffType } from '../enums/IterableRetryBackoffType';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]


/**
* Configuration class for JWT refresh retry behavior.
* Maps to the native RetryPolicy class in Android/iOS SDKs.
*/
export interface IterableRetryPolicy {
/** Number of consecutive JWT refresh retries the SDK should attempt */
maxRetry: number;
/**
* Duration between JWT refresh retries in seconds
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete · [eslint:prettier/prettier]

Suggested change
* Duration between JWT refresh retries in seconds
* Duration between JWT refresh retries in seconds

* (starting point for retry backoff)
*/
retryInterval: number;
/** The backoff pattern to apply between retry attempts */
retryBackoff: IterableRetryBackoffType;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insert [eslint:prettier/prettier]

1 change: 1 addition & 0 deletions src/core/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './IterableEdgeInsetDetails';
export * from './IterableAuthFailure';
export * from './IterableRetryPolicy';
3 changes: 2 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ export {
IterableEventName,
IterableLogLevel,
IterablePushPlatform,
IterableRetryBackoffType,
} from './core/enums';
export {
useAppStateListener,
useDeviceOrientation,
type IterableDeviceOrientation,
} from './core/hooks';
export { type IterableEdgeInsetDetails } from './core/types';
export type { IterableEdgeInsetDetails, IterableRetryPolicy, IterableAuthFailure } from './core/types';
export {
IterableHtmlInAppContent,
IterableInAppCloseSource,
Expand Down